Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a VPS production server that serves web apps that I make for clients. I have an rsync cron job running on my dev server that does a daily backup of the entire production server.

#!/bin/sh

RSYNC=/usr/bin/rsync
SSH=/usr/bin/ssh
KEY=/root/backup-rsync-key
RUSER=root
RHOST=xxx.xxx.xxx.xxx
LPATH=/home/backup
RPATH=/

$RSYNC -avz -e "$SSH -i $KEY" $RUSER@$RHOST:$RPATH $LPATH

It works OK but gives errors of the type:

...
rsync: read errors mapping "/sys/module/yenta_socket/parameters/disable_clkrun": No data available (61)
ERROR: sys/module/yenta_socket/parameters/isa_probe failed verification -- update discarded.
rsync: read errors mapping "/sys/module/yenta_socket/parameters/isa_probe": No data available (61)
ERROR: sys/module/yenta_socket/parameters/pwr_irqs_off failed verification -- update discarded.
rsync: read errors mapping "/sys/module/yenta_socket/parameters/pwr_irqs_off": No data available (61)
ERROR: sys/power/state failed verification -- update discarded.
rsync: read errors mapping "/sys/power/state": No data available (61)
rsync error: some files could not be transferred (code 23) at main.c(1298) [generator=2.6.8]

(this is just a snippet of the errors)

How can I backup everything except for the stuff that won't backup?

Thanks

share|improve this question

3 Answers 3

up vote 7 down vote accepted

You have to exclude unnecessary files.

Good start is -x

-x, --one-file-system       don't cross filesystem boundaries

(from man rsync(1)). That excludes filesystems you didn't specify explicitly. Remember that then you have to list all mount points you want to include. mount gives list for you.

Another useful option is --exclude:

--exclude=PATTERN       exclude files matching PATTERN
--exclude-from=FILE     read exclude patterns from FILE

Your command would be something like

rsync -avzx --exclude=/tmp --exclude=/var/cache -e "$SSH -i $KEY" $RUSER@$RHOST:$RPATH $LPATH
share|improve this answer
    
Thanks - I've just been testing your solution and it appears to work now without any errors appearing. I also excluded /sys and /proc since they were causing a few errors. –  Xoundboy Feb 22 '11 at 11:39
    
You should exclude /tmp too, backing up temporary files is foolish. –  Olli Feb 22 '11 at 11:43

You can exclude specific files using the --exclude option, like '--exclude=/sys'. Also, you can use the --exclude-from option to exclude files listed in a specific file.

share|improve this answer

Have a look at the --exclude-from command line option that allows you to define a file that contains a list of files and directories that rsync should exclude.

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.