Backup Data before user Deletion in Linux
Backup Commands in Unix-like Systems
| Command | Purpose | Key Options | Example |
|---|---|---|---|
| Backup Commands | Example: | ||
tar | Create compressed archive of files or directories | -czf (create, compress with gzip), -cf (create, no compression) | 1. Backup /home/john to john_backup.tar.gz: tar -czf john_backup.tar.gz /home/john |
rsync | Sync files and directories to a backup location | -a (archive mode), -v (verbose), --delete (remove files not in source) | 1. Backup /home/john to /backup/home/john: rsync -av /home/john /backup/home/john |
cp | Copy files or directories | -r (recursive), -a (archive) | 1. Backup /home/john to /backup/home/john: cp -a /home/john /backup/home/john |
Example Usage:
- Backup Commands:
- Create a Compressed Archive with
tar:bashCopy codetar -czf john_backup.tar.gz /home/johnThis command creates a compressed backup of the/home/johndirectory and saves it asjohn_backup.tar.gz. - Sync Files with
rsync:bashCopy codersync -av /home/john /backup/home/johnThis command syncs the/home/johndirectory to/backup/home/john, preserving file attributes and providing verbose output. - Copy Files with
cp:bashCopy codecp -a /home/john /backup/home/johnThis command creates a backup of the/home/johndirectory to/backup/home/john, preserving file attributes.
- Create a Compressed Archive with
