1

I have a central CentOS 7 backup server, where I run the following rsync command in a script to pull the Application logs from 100's of Linux machines and then delete them.

rsync --remove-source-files --include-from=/tmp/$MACHINE_file.lst \
  -v -a -l -K --rsh=ssh --stats $MACHINE:/ $BACKUPDIR/$MACHINE

I generate /tmp/file.lst on the central backup machine for each machine using other script; It contains the following directories and files to be backed up.

+ /data1/
+ /data2/
+ /data2/sample/
- *

But recently I encountered a big problem where the /tmp partition on the central backup server became full due to some other problem and hence /tmp/$MACHINE_file.lst could not be created. This created a problem where rsync started deleting the files from / partition on the source machines. Any idea why?

meuh
  • 1,563
  • 10
  • 11
devops
  • 11
  • 1
  • Perhaps if you follow arg `--include-from=...` with a redundant `--exclude='*'` it will guarantee that if the .lst file fails, you will still have the "exclude everything" default working. – meuh May 13 '20 at 05:37

1 Answers1

0
  • tmp directory filled up and file.lst could not be created
  • rsync ignored the --include-from directive since that file did not exist and included everything on the source since you specified the / directory in your command
  • unfortunately you also specified --remove-source-files
  • since those files didn't exist on your target it did exactly as you asked - synced everything to the target and deleted everything on the source.
Peleion
  • 303
  • 1
  • 7
  • Thanks , can i specify /tmp directory in the command , instead / , will rsync still consider only those directories and files listed in the --include-from=/tmp/$MACHINE_file.lst – devops May 12 '20 at 04:05