Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[solved] rsync w/ exclude/include files
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
toralf
Developer
Developer


Joined: 01 Feb 2004
Posts: 3925
Location: Hamburg

PostPosted: Wed Oct 05, 2011 8:58 am    Post subject: [solved] rsync w/ exclude/include files Reply with quote

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
View user's profile Send private message
aCOSwt
Bodhisattva
Bodhisattva


Joined: 19 Oct 2007
Posts: 2537
Location: Hilbert space

PostPosted: Wed Oct 05, 2011 11:01 am    Post subject: Reply with quote

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
View user's profile Send private message
toralf
Developer
Developer


Joined: 01 Feb 2004
Posts: 3925
Location: Hamburg

PostPosted: Wed Oct 05, 2011 1:38 pm    Post subject: Reply with quote

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
View user's profile Send private message
aCOSwt
Bodhisattva
Bodhisattva


Joined: 19 Oct 2007
Posts: 2537
Location: Hilbert space

PostPosted: Wed Oct 05, 2011 1:57 pm    Post subject: Reply with quote

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
View user's profile Send private message
toralf
Developer
Developer


Joined: 01 Feb 2004
Posts: 3925
Location: Hamburg

PostPosted: Thu Oct 06, 2011 4:46 pm    Post subject: Reply with quote

I both used -D and changed the order of in/ex-clude - now it works :-)
Back to top
View user's profile Send private message
gentoo_ram
Guru
Guru


Joined: 25 Oct 2007
Posts: 475
Location: San Diego, California USA

PostPosted: Thu Oct 06, 2011 10:16 pm    Post subject: Reply with quote

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
View user's profile Send private message
toralf
Developer
Developer


Joined: 01 Feb 2004
Posts: 3925
Location: Hamburg

PostPosted: Fri Oct 07, 2011 7:30 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum