Linux System Administration

0 of 85 lessons complete (0%)

Managing User Accounts

Backup Data before user Deletion in Linux

You don’t have access to this lesson

Please register or sign in to access the course content.

Backup Commands in Unix-like Systems

CommandPurposeKey OptionsExample
Backup CommandsExample:
tarCreate 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
rsyncSync 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
cpCopy files or directories-r (recursive), -a (archive)1. Backup /home/john to /backup/home/john: cp -a /home/john /backup/home/john

Example Usage:

  1. Backup Commands:
    • Create a Compressed Archive with tar:bashCopy codetar -czf john_backup.tar.gz /home/john This command creates a compressed backup of the /home/john directory and saves it as john_backup.tar.gz.
    • Sync Files with rsync:bashCopy codersync -av /home/john /backup/home/john This command syncs the /home/john directory to /backup/home/john, preserving file attributes and providing verbose output.
    • Copy Files with cp:bashCopy codecp -a /home/john /backup/home/john This command creates a backup of the /home/john directory to /backup/home/john, preserving file attributes.