Thursday, June 2, 2011

Backup a linux system


source: https://help.ubuntu.com/community/BackupYourSystem/TAR

Summary: the backup can be done from the system directly (i.e. no need to run from a live CD). We don't want to backup some directories: proc, sys and dev are virtual filesystems... lost+found is not useful. -p option in tar is to preserve permissions.

 sudo tar -cvpzf /backup.tar.gz -–exclude=/backup.tar.gz --exclude=/proc --exclude=/lost+found --exclude=/sys --exclude=/dev --exclude=/mnt --exclude=/media /  

For restoration: this must be done from another system, typically a live cd. We will restore to /mnt:

 sudo tar -xvpzf backup.tar.gz -C /mnt  

then recreate the missing directories:
 mkdir /proc /lost+found /sys /mnt /media  

and install grub:
 sudo grub-install --root-directory=/mnt /dev/sdc  

No comments:

Post a Comment