Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Last time I backed up my data by copying and pasting my home directory into my external hard drive. Since then, I have added and deleted files from my home directory. I want to update that directory in my hard drive, so that I back up only newly added files, and I don't have to make a second copy of my home directory. This takes less space and time.

Now the difficulty seems to be that the directory structure in my laptop has changed. Some file locations might have changed. There are newly added and deleted files. So I want to use ideally the Ubunthu command line, maybe rsync, so that for each file in my laptop home, it searches all files on my home directory on the external drive, and if it's found somewhere there, don't copy, if it's not found, copy it. If a corresponding sub-directory exists, new files are added there. If not, create the corresponding sub-directory.

In general how do you go about updating your existing backup?

Thanks

share|improve this question

3 Answers 3

Rsync on its own supports incremental backup. You can use the '-i' option to view the changes between source & destination directory.

Usage would be;

rsync -avzi root@hostip:/var/big /root/tmp

share|improve this answer
    
I understand that rsync has update and backup option. But would it work when the directory structure has changed? how does it handle added/dropped sub-directories? –  eli Sep 22 '14 at 16:27

To avoid these kinds of issues the normal sysadmin approach is to separate each backup from the others. A simple way to do this is to save the data into a single file with the current date or timestamp in the name. tar can do this easily:

tar -cf "/backups/$(date +%Y%m%dT%H%M%S).tar" /some/path

If it's easily compressible data (such as text files) you can also compress the result to minimise the disk use:

tar -zcf [...]

With this approach it's easy to go back to any version you want, and it works very well with other tools such as logrotate.

share|improve this answer
    
But it wont be an incremental update back up; it's like copy pasting the whole thing again, including common files. –  eli Sep 22 '14 at 16:24
    
Yep. But remember that disk space is cheap, and developer time is expensive. Simple is often cheaper. –  l0b0 Sep 22 '14 at 18:44

I think rsnapshot will be ideal for you. It uses rsync, will make incremental differential backups of your home directory, so that you can get back to data backed-up a while (for instance week) ago. It will not copy whole every time but only what has changed. Easy to setup, all commandline.

HTH, Cheers

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.