| name | backup |
| description | Backup files or directories following standard naming conventions with CST timestamps and optional checksums. Use this skill before destructive operations. |
Backup files and directories
When to use
Before any destructive operation, or when explicitly asked to create a backup.
Instructions
- Read the full CoT: Load and follow
~/rules/cot/backup.md from line 1 to end
- Generate timestamp:
TS=$(TZ=America/Mexico_City date +"%Y-%m-%dT%H-%M-%S")
- Name the backup:
[name_without_ext]_[timestamp].[original_ext].bkp
- For files:
cp source.txt backups/source_${TS}.txt.bkp
- For directories:
tar --owner=0 --group=0 --numeric-owner -cf - dir/ | zstd -T0 -19 -o "dir_${TS}.tar.zst"
- Checksum (if >= 100 MB):
sha256sum backup_file > backup_file.sha256
- Verify: Confirm the backup exists and is readable
Naming examples
archivo.txt → archivo_2026-03-27T17-30-00.txt.bkp
config.yaml → config_2026-03-27T17-30-00.yaml.bkp
Critical rules
- All timestamps use CST (Ciudad de México, UTC-6)
- Never overwrite previous backups
- Checksums (.sha256) required for files >= 100 MB
- Use zstd compression for directories
References
- Detailed CoT:
~/rules/cot/backup.md
- Rules:
~/rules/rulesets/BACKUPS.md
- Script:
~/rules/scripts/backup_file.sh