1

I'm not sure why this is not working as expected. I have a full rsync backup of /scripts/source in /scripts/full and want to put differential backup into /scripts/diff However, when a file is added to the origin location of /scripts/source and then a differential backup is run, the files are backed up to /scripts/full instead of /scripts/diff Here's a test script I made:

DIFF='/scripts/diff'
SOURCE='/scripts/source'
FULL='/scripts/full'
CTIME=$(date +%T)
TESTFILE=newfile$CTIME
rm -r $DIFF/*
rm $SOURCE/newfile*
rm $FULL/newfile*
echo "I'm in a file " >  $SOURCE/$TESTFILE
rsync \
-a \
-A \
-X \
-h \
-H \
-b \
--backup-dir=$DIFF \
$SOURCE/* \
$FULL
echo "----------------------------------------------------------------------"
echo "Our test file is: $TESTFILE"
echo "----------------------------------------------------------------------"
echo "Source Files in $SOURCE - we should see our one test file"
ls $SOURCE
echo "----------------------------------------------------------------------"
echo "Full backup in past - We should not see any test files here"
ls $FULL
echo "----------------------------------------------------------------------"
echo "Diff files in $DIFF  - we should see the same test file here as"
echo "was in the $SOURCE dir"
ls $DIFF

In the script, the test file gets dropped in the source directory. rsync should not copy it the full directory (but it does). It should be copied to the diff directory (it isn't).

Re-reading the man pages and searching the web has not helped. Simple differential backup schemes when adapted for my environment simply do not work. What am I doing wrong here? I want to do a full backup once in a while. Then I want to run subsequent diffs that contain only the changed files (while the full backup never changes). Idea being that there's a full backup to reference, and changed files can be found in the diff. My script is more complex than this, but I simplified it to isolate the issue. Thanks, -Jeff

0

1 Answer 1

0

I suppose the options -b --backup-dir do not act as you hope.
You can try to use a different option --link-dest instead. Your command line should be similar to the following

rsync -aAXhH --link-dest=/scripts/full/  /scripts/source/  /scripts/diff/

What's the meaning?
You are telling to rsync to compare the files in /scripts/source/ (the new ones) with the ones in /scripts/diff/ (that is empty) and in the additional directory /scripts/full/ (That is the one of your backup).

Notes:

  • Usually it's better to protect the variable with double quote "". So better TESTFILE="newfile${CTIME}" then TESTFILE=newfile$CTIME
  • From man rsync:

    --link-dest=DIR         hardlink to files in DIR when unchanged
    
  • The options --backup-dir(...) are probably used to do a copy of the file usually with a different extension or in a different directory instead to overwrite file in the destination directory.

    -b, --backup                make backups (see --suffix & --backup-dir)
        --backup-dir=DIR        make backups into hierarchy based in DIR
        --suffix=SUFFIX         backup suffix (default ~ w/o --backup-dir)
    
  • Yes they should be less nebulous...

You must log in to answer this question.

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