How to Do a Differential Backup for Linux
Backing up your computer files allows you to restore your computer to its previous settings easily after a loss of data. A differential backup saves any changes made since the last full backup of your system. This method works faster than a full backup since it saves only files that have changed since your last full backup. Restoring your files using differential backup also works faster for the same reason. In Linux, you can create a differential backup using a few simple commands.
Things You'll Need
- External storage device (external hard disk drive or USB flash drive)
- Computer running the Linux operating system
- Knowledge of Unix Shell and basic Unix commands
Instructions
-
-
1
Connect the external storage device to your computer.
-
2
Open a text editor (examples of text editors in Linux include gedit, GNU Emacs, and vim), and type the following commands:
DATE=$(date +"%d-%m-%Y")
FILE="$DATE-backup.tar.gz"
tar -g /root/gnutar.incremental.txt -zcvf $FILE /home
These commands save the contents of your /home directory in .tar file format. The backup file name will contain the date you created it (for example, "25-12-2008-backup.tar.gz" if you created it on December 25, 2008). Save the file as "diff-backup.sh" (without quotation marks).
-
-
3
Enter the command "chmod +x diff-backup.sh" (without quotation marks) in the shell, which will allow you to run the script.
-
4
Run the script using the command "./diff-backup.sh" (without quotation marks). Expect the process to take some time, depending on how many files you are backing up.
-
5
Once the backup completes, you can move the backup file to the external storage device using the "mv" command, or click and drag the file into the storage device using the file manager.
-
1
Tips & Warnings
You can automate the backup process using the cron job scheduler. For more information, type "man cron" or "man crontab" (without quotation marks) into the terminal window.
Ensure the computer properly detects the external storage device. If the computer does not automatically detect the external storage device, you may need to mount it manually.
Before running a differential backup, you should already have a full backup. To create a full backup, use the command "tar -zcvf full-backup.tar.gz /home" (without quotation marks).
You may need administrative privileges (become "root") to run certain commands. Be careful what commands you run when you have these privileges, as you can cause irreversible damage to your file system.
References
- Photo Credit memory stick usb image by Photosani from Fotolia.com