SDB:Home backup
Backup your /home
When /home directory is on a standalone partition then very few things can go wrong, but it is always a good idea to create a backup.
What to backup
Find if /home has its own Partition
To find out if your home is on its own partition you can use df like this
df -h | grep /home
If the result is similar to this
/dev/sda4 122G 8.7G 107G 8% /home
then it is mounted in its own partition. Note that in case you want to backup the space you need on the backup media is the number shown in the second column (8.7G here).
If you dont get anything as a result of the last command then it is a directory under / and you should take a backup to an external medium.
How to find the size of /home if its under /
You can either visit /home using your file manager (Konqueror/Dolphin/Nautilus) and right click on the directory and select properties or use the terminal and type
du -sh /home/
The result will look similar to this
8.5G /home/
Special care should be taken in case you have windows or another distro installed and you mounted it under /home/windows in this case this will be counted also as well as all the other user homes. You can give du the exact path you want counted, for example if your username is openSUSE then you should type this in the terminal
du -sh /home/openSUSE
The result will look similar to this
8.5G /home/openSUSE/
Backup Procedures
tar
You can create a compressed tar file with a full backup of your home directory using the following
Backup
This will create a backup of user openSUSE in a file called myBackup.tgz inside the /home directory.
sudo tar cpzvf /home/myBackup.tgz --same-owner /home/openSUSE/
Incremental Backup
At a latter time you can add new files to your backup using the following
sudo tar cvzpnf /home/myBackup.tgz --same-owner /home/openSUSE/
Compare / Verify
After the backup you can do a compare of the backed up files using the following
tar tzvf /home/myBackup.tgz -C /home/openSUSE/
Restore
To restore the backed up files use the following
sudo tar zxvf /home/temp.tgz -C /
rsync
dd
If your /home is in a dedicated partition you can do a bit by bit copy (clone) using dd, you can either clone the partition to another partition or create an image of it and restore it latter.
Partition Cloning
To copy the /home partition to another partition as root type
dd if=/dev/sda4 of=/dev/sdb2
Partition Image
To copy the /home partition to a file, type
dd if=/dev/sda4 of=/yourFilename.dd
To restore the partition from the file, type
dd if=/yourFilename.dd of=/dev/sda4
Partition Image with Compression (gzip) and Split
The following will create 650MB gzip compressed files of the disk
dd if=/dev/sda4 | gzip -c | split -b 650m - homedisk.dd.gz_
To restore use the following
cat homedisk.dd.gz_* | gzip -dc | dd of=/dev/hda4