2

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

3 Answers 3

7

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
2
  • 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
    Commented Feb 22, 2011 at 11:39
  • You should exclude /tmp too, backing up temporary files is foolish.
    – Olli
    Commented Feb 22, 2011 at 11:43
1

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.

0

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .