Warning: 2015-10-19: Major upgrade in progress. Site somewhat functional, with bugs...

Detailed example of rsync-incr operation

Let's say we have a source directory, dir that we are going to backup into backup with default options and backup--snap with --snap. We will have in it the files:
  • On Day 1
    • B
    • C
    • D
  • On Day 2
    • A is Added
    • B stay the same in Both days
    • C is Changed
    • D is Deleted and not there anymore

So, on Day 1:

We set up the source
# mkdir dir; echo bbb >dir/B;echo ccc >dir/C;echo ddd >dir/D
# ls -l dir
total 12
-rw-rw-r-- 1 colas local 4 Jan 10 23:40 B
-rw-rw-r-- 1 colas local 4 Jan 10 23:40 C
-rw-rw-r-- 1 colas local 4 Jan 10 23:40 D

We backup normally

# rsync-incr 5 dir backups/dir
# ls -lR backups
backups:
total 8
drwxrwxr-x 2 colas local 4096 Jan 10 23:40 dir
drwxrwxr-x 2 colas local 4096 Jan 10 23:42 dir.past

backups/dir:
total 12
-rw-rw-r-- 1 colas local 4 Jan 10 23:40 B
-rw-rw-r-- 1 colas local 4 Jan 10 23:40 C
-rw-rw-r-- 1 colas local 4 Jan 10 23:40 D

backups/dir.past:
total 4
-rw-rw-r-- 1 colas local 17 Jan 10 23:42 LAST_DATE
We backup with --snap

# rsync-incr --snap 5 dir backups--snap/dir
# ls -lR backups--snap
backups--snap:
total 8
drwxrwxr-x 2 colas local 4096 Jan 10 23:40 dir
drwxrwxr-x 3 colas local 4096 Jan 10 23:44 dir.past

backups--snap/dir:
total 12
-rw-rw-r-- 1 colas local 4 Jan 10 23:40 B
-rw-rw-r-- 1 colas local 4 Jan 10 23:40 C
-rw-rw-r-- 1 colas local 4 Jan 10 23:40 D

backups--snap/dir.past:
total 8
drwxrwxr-x 2 colas local 4096 Jan 10 23:44 2009-01-10.23h44-0m
-rw-rw-r-- 1 colas local 17 Jan 10 23:44 LAST_DATE

backups--snap/dir.past/2009-01-10.23h44-0m:
total 0

On day 2

We set up the source
# rm dir/D; echo aaa>dir/A; echo CCC>dir/C
# ls -l dir/
total 12
-rw-rw-r-- 1 colas local 4 Jan 10 23:48 A
-rw-rw-r-- 1 colas local 4 Jan 10 23:40 B
-rw-rw-r-- 1 colas local 4 Jan 10 23:48 C

We backup normally

# rsync-incr 5 dir backups/dir
# ls -lR backups
backups:
total 8
drwxrwxr-x 2 colas local 4096 Jan 10 23:48 dir
drwxrwxr-x 3 colas local 4096 Jan 10 23:50 dir.past

backups/dir:
total 12
-rw-rw-r-- 1 colas local 4 Jan 10 23:48 A
-rw-rw-r-- 1 colas local 4 Jan 10 23:40 B
-rw-rw-r-- 1 colas local 4 Jan 10 23:48 C

backups/dir.past:
total 8
drwxrwxr-x 2 colas local 4096 Jan 10 23:50 2009-01-10.23h42-1m
-rw-rw-r-- 1 colas local 17 Jan 10 23:50 LAST_DATE

backups/dir.past/2009-01-10.23h42-1m:
total 8
-rw-rw-r-- 1 colas local 4 Jan 10 23:40 C
-rw-rw-r-- 1 colas local 4 Jan 10 23:40 D

You can see that backups/dir contains a perfect copy of the current dir, but in backups/dir.past you can look at the state of the directory the "day" before as only the old versions of files that have changed or been deleted, unchanged ones are not present.You see only the list of changes (in reverse: changes as compared with the day after)

We backup with --snap
# rsync-incr --snap 5 dir backups/dir
# ls -lR backups--snap/:
total 8
drwxrwxr-x 2 colas local 4096 Jan 10 23:30 dir
drwxrwxr-x 4 colas local 4096 Jan 10 23:30 dir.past

backups--snap/dir:
total 12
-rw-rw-r-- 1 colas local 4 Jan 10 23:30 A
-rw-rw-r-- 2 colas local 4 Jan 10 23:27 B
-rw-rw-r-- 1 colas local 4 Jan 10 23:30 C

backups--snap/dir.past:
total 12
drwxrwxr-x 2 colas local 4096 Jan 10 23:30 2009-01-10.23h30-0m
drwxrwxr-x 2 colas local 4096 Jan 10 23:27 2009-01-10.23h30-1m
-rw-rw-r-- 1 colas local 17 Jan 10 23:30 LAST_DATE

backups--snap/dir.past/2009-01-10.23h30-0m:
total 0

backups--snap/dir.past/2009-01-10.23h30-1m:
total 12
-rw-rw-r-- 2 colas local 4 Jan 10 23:27 B
-rw-rw-r-- 1 colas local 4 Jan 10 23:27 C
-rw-rw-r-- 1 colas local 4 Jan 10 23:27 D
There, you can see that the "past" backup dir contains an image of the whole of dir the "day" before. But you see that B has a link count of 2 so is shared between the 2 backup dirs, whereas C is not, the 2 C files have different contents

Topic revision: r11 - 10 Jan 2009, ColasNahaboo
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Colas? Send feedback