LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   backup changed files only. (https://www.linuxquestions.org/questions/linux-software-2/backup-changed-files-only-606329/)

deadlock 12-12-2007 11:56 AM

backup changed files only.
 
Trying to work out whether the following is possible.

Day 1: Backup all files
Day 2: Backup only those files changed from Day 1
Day 3: Backup only files changed from Day 2
Day 4: etc...
Day 8: Full backup...

Therefore to get back to Day 3 you restore your Day 1, 2 and 3 backups in sequence.

rsync --backup seems to do the reverse of what I want - i.e. I get a folder with all the Day 1 files, a folder with Day 1 + Day 2 files, a folder with Day 1, Day2 + Day 3 files...

Any pointers?

pljvaldez 12-12-2007 11:58 AM

I use Backuppc to do just this. It utilizes rsync as well.

matthewg42 12-12-2007 12:02 PM

There are similar cases to this on the rsync examples page: http://rsync.samba.org/examples.html

Or an alternative approach described here: http://www.mikerubel.org/computers/r...s/#Incremental

deadlock 12-13-2007 04:23 AM

I can only get the the rsync examples to do the reverse of what I want.

For example if files have not changed over the week, then I get 7 copies of same file (1 in each incremental folder). I only want those files in the Day 1 backup.

Will check the other suggestions.

matthewg42 12-13-2007 05:36 AM

Which method do you use?

deadlock 12-13-2007 05:44 AM

Code:

BACKUPDIR=~/test/backups/`date +%R:%S`
rsync -b --backup-dir=$BACKUPDIR -rv testsrc/ ~/test/backups/current

Backupdir is H:M:S for testing - will by %F when live

If you run the above without changing anything in testsrc you get a new "dated" folder identical to "current"

choogendyk 12-13-2007 07:41 PM

Are you sure you aren't looking at hard links? You may have a single copy of an unchanged file and the folder with the image of all the directory structure on the next occasion has a hard link to it because it hasn't changed. For files that changed, it may remove the link and then copy the new file in. I'm speculating from your description, but this is the way some procedures work.

deadlock 12-14-2007 04:50 AM

Definatly not links.

Steps as follows:

1) Create folder in ~ called test
2) Create folder ~/test/testsrc and ~/test/backups
3) Create script containing only the code given above
4) touch testsrc/test1.txt
5) Run the script
6) touch testsrc/test2.txt

At this point you should have the following tree in backups:

~/test/backups/current/test1.txt
~/test/backups/current/test2.txt
~/test/backups/10:45:00/test1.txt

Edit test1.txt in current and it has no effect on test1.txt and vice versa

choogendyk 12-14-2007 08:03 AM

What I meant was links between your multiple backups. The explicit example you just gave is only one backup.

However, looking into it a bit more, it's pretty clear this isn't the issue. You are simply creating new directories and doing new full backups.

Check out the link mathewg42 gave to Mike Rubel's web page. Or get a copy of the O'Reilly book "Backup & Recovery" by W. Curtis Preston. This is all spelled out in Chapter 7 which covers rsync with snapshots, rsnapshot, rdiff, etc. rsnapshot implements the whole procedure and may be available with your distribution.

If you want to script it yourself with rsync, the basic idea is to first create a full backup with rsync. Then replicate the full backup using only hardlinks. Then rsync to the replicate letting it delete the links for those files that have changed and copy the new files in. Repeat the process on the most recent replicate of the backup. I would also change the -rv that you are using to -av. That catches more options that you want for a backup.

so, initially

Code:

BACKUPDIR=~/test/backups/`date +%R:%S`
rsync -av testsrc/. $BACKUPDIR

then

Code:

NEWDIR=~/test/backups/`date +%R:%S`    {this will be different now}
cp -al $BACKUPDIR/. $NEWDIR/            {copy is all just links}
rsync --delete -av testsrc/. $NEWDIR    {replace links only for changed content}

There are variations on this, and there are options in rsync that will create the links. And there is also rsnapshot. And, of course, jumping off in other directions, BackupPC, Amanda, . . . which can get more complicated.

deadlock 12-14-2007 11:36 AM

In the end I found a script example using find and tar taht does what I want.

So now if it's a Sunday I do a full backup of the source tree, and every other day do the same for files changed in the last 24 hours.

Thanks for the help

Dan


All times are GMT -5. The time now is 08:30 PM.