View previous topic :: View next topic |
Author |
Message |
toralf Developer
Joined: 01 Feb 2004 Posts: 3925 Location: Hamburg
|
Posted: Wed Oct 05, 2011 8:58 am Post subject: [solved] rsync w/ exclude/include files |
|
|
I wondering how to tell rsync to exclude the directory /dev except the file /dev/null for a full backup of my system (/dev/zero is necessary, all other entries are handled by udevd AFAIK).
This seems not to work : Code: | tfoerste@n22 ~ $ grep /dev/ /*.list
/exclude.list:/dev/*
/include.list:/dev/zero
|
Last edited by toralf on Thu Oct 06, 2011 4:47 pm; edited 1 time in total |
|
Back to top |
|
|
aCOSwt Bodhisattva
Joined: 19 Oct 2007 Posts: 2537 Location: Hilbert space
|
Posted: Wed Oct 05, 2011 11:01 am Post subject: |
|
|
do you rsync -D (--devices) ?
Edit : BTW, last time I restored my backups from scratch, I needed to recreate /dev/console et /dev/null too. _________________
|
|
Back to top |
|
|
toralf Developer
Joined: 01 Feb 2004 Posts: 3925 Location: Hamburg
|
Posted: Wed Oct 05, 2011 1:38 pm Post subject: |
|
|
I use such a loop : Code: | OPTS="--archive --cvs-exclude --delete --delete-excluded --exclude-from=/exclude.list --include-from=/include.list --itemize-changes --link-dest=$REF"
for SRC in $(ls -d /* 2>/dev/null)
do
rsync $OPTS $SRC $DST/
if [[ $? -ne 0 ]]; then
break
fi
done
| to create backups of my whole system onto an external (encrypted) USB drive. |
|
Back to top |
|
|
aCOSwt Bodhisattva
Joined: 19 Oct 2007 Posts: 2537 Location: Hilbert space
|
Posted: Wed Oct 05, 2011 1:57 pm Post subject: |
|
|
So my understanding is that you do not backup any devices per default as you do not include the --devices (-D) option.
I suggest you test with this option set. _________________
|
|
Back to top |
|
|
toralf Developer
Joined: 01 Feb 2004 Posts: 3925 Location: Hamburg
|
Posted: Thu Oct 06, 2011 4:46 pm Post subject: |
|
|
I both used -D and changed the order of in/ex-clude - now it works |
|
Back to top |
|
|
gentoo_ram Guru
Joined: 25 Oct 2007 Posts: 475 Location: San Diego, California USA
|
Posted: Thu Oct 06, 2011 10:16 pm Post subject: |
|
|
Another approach is to use a mount bind to re-mount the root filesystem somewhere else. That will uncover the contents of /dev on your disk before udev is started. This way you can backup exactly what is on your root filesystem and not have to worry about the other mounts like /sys, /dev, and /proc.
Code: | mount -o bind / /mnt/root
rsync -av /mnt/root/ /mnt/backup/root/ |
... or with whatever options you want. This is what I use for my backups. |
|
Back to top |
|
|
toralf Developer
Joined: 01 Feb 2004 Posts: 3925 Location: Hamburg
|
Posted: Fri Oct 07, 2011 7:30 am Post subject: |
|
|
Good hint.
I think that most content of /dev, /proc and /sys will be created by the kernel and udevd except the character file /dev/zero, which seems to be expected as a character device to successfully boot into a rsync'ed archive. |
|
Back to top |
|
|
|