Linux Server – Backup the entire system using tar with compression

Viewing 1 post (of 1 total)
  • Author
  • #14144

    The above command is on multiple lines for readability. Enter everything on the same line when entering the command in the editor. Once entered, exit the editor (Ctrl-X) saving the file.

    The c option creates the backup file.
    The v option gives a more verbose output while the command is running. This option can also be safely eliminated.
    The p option preserves the file and directory permissions.
    The f option needs to go last because it allows you to specify the name and location of the backup file which follows next in the command (in our case this is the /mnt/fullbackup.tar.gz file).
    To enable the compression you have to add the z switch to both the tar-ing and untar-ing commands. You also have to change the file name to indicate the compression. Our tar-ing command becomes:
    The –directory option tells tar to switch to the root of the file system before starting the backup.
    We –exclude the directory that contains are backup file.

    tar -zcvpf /mnt/backup/wholesystem.tar.gz --directory=/ --exclude=proc --exclude=sys --exclude=dev/pts --exclude=backups .

    Likewise, our untar-ing command becomes:

    tar -zxvpf /fullbackup.tar.gz
Viewing 1 post (of 1 total)

You must be logged in to reply to this topic. Login here