4

I seem to be having trouble getting this rsync script to work the way I need it to. The source is here. The idea behind it is to create incremental backups, similar to what MacOS's Time Machine does. I think I understand how all the parts work, and I modified it for my own use. The problem is that while backups are being made, rsync is also generating errors. My version of the script is:

#!/bin/bash

# create a date variable for backup naming
date=`date "+%Y-%m-%dT%H%M%S"`
backupdir="/media/USER/SEAGATE/MintBackups"

# use all options for -a for convenience, plus progess meter with -P
# --delete: delete from $DEST what isn't in $SOURCE
# --log-file: save a log file somewhere (make sure not to sync this)
# -C: don't sync cvs stuff (like .git directories)
# --exclude-from: use this file to exclude files from syncing
# --link-dest: hardlink in this directory
rsync -aPK --delete --log-file=tmp/rsync-log.log -C --exclude-from=sync_exclusions.txt --link-dest=/media/USER/SEAGATE/MintBackups/current /home/USER/ /media/USER/SEAGATE/MintBackups/USER-$date
rm -f $backupdir/current
ln -s $backupdir/USER-$date $backupdir/current

I'm using the -K flag to preserve symlinks (since I wasn't getting the right results with just -a). However, the directory I'm symlinking to is in my Dropbox folder, which I've excluded. Could that be a problem?

Additionally, the part where --link-dest is used fails because it doesn't exist prior to the script running, yet the original author mentioned nothing about creating the link beforehand. Thus, I don't know if I'm supposed to create it beforehand or if there's something else going on.

The errors I'm getting are of the form:

2016/12/30 23:24:50 [26974] rsync: mkstemp "/media/USER/SEAGATE/MintBackups/USER-2016-12-30T232102/Pictures/.Screenshot - 10242016 - 05:05:43 PM.png.IGSO2W" failed: Invalid argument (22)
2016/12/30 23:24:50 [26974] rsync: mkstemp "/media/USER/SEAGATE/MintBackups/USER-2016-12-30T232102/Pictures/.Screenshot from 2016-03-06 05:55:01.png.qY6sWu" failed: Invalid argument (22)
2016/12/30 23:24:50 [26974] rsync: mkstemp "/media/USER/SEAGATE/MintBackups/USER-2016-12-30T232102/Pictures/.Screenshot from 2016-03-08 09:05:02.png.4PbFU2" failed: Invalid argument (22)
2016/12/30 23:24:50 [26974] rsync: mkstemp "/media/USER/SEAGATE/MintBackups/USER-2016-12-30T232102/Pictures/.Screenshot from 2016-03-09 11:48:34.png.mqR1VA" failed: Invalid argument (22)
2016/12/30 23:24:50 [26974] rsync: mkstemp "/media/USER/SEAGATE/MintBackups/USER-2016-12-30T232102/Pictures/.Screenshot from 2016-03-10 12:53:35.png.WuoxZ8" failed: Invalid argument (22)
2016/12/30 23:24:50 [26974] rsync: mkstemp "/media/USER/SEAGATE/MintBackups/USER-2016-12-30T232102/Pictures/.Screenshot from 2016-04-28 11:34:34.png.goaX3G" failed: Invalid argument (22)
2016/12/30 23:24:50 [26974] rsync: mkstemp "/media/USER/SEAGATE/MintBackups/USER-2016-12-30T232102/Pictures/.Screenshot from 2016-05-03 19:31:07.png.9Wllaf" failed: Invalid argument (22)
2016/12/30 23:24:50 [26974] rsync: mkstemp "/media/USER/SEAGATE/MintBackups/USER-2016-12-30T232102/Pictures/.Screenshot from 2016-05-30 15:38:01.png.kFg2hN" failed: Invalid argument (22)
2016/12/30 23:24:50 [26974] rsync: mkstemp "/media/USER/SEAGATE/MintBackups/USER-2016-12-30T232102/Pictures/.Screenshot from 2016-06-03 20:55:37.png.vNj3sl" failed: Invalid argument (22)
2016/12/30 23:24:50 [26974] rsync: mkstemp "/media/USER/SEAGATE/MintBackups/USER-2016-12-30T232102/Pictures/.Screenshot from 2016-07-01 12:16:11.png.FReAGT" failed: Invalid argument (22)

I also received an error that rsync couldn't create a symlink on the external disk, that the operation was forbidden.

In other words, I'm not exactly sure what mistake(s) I'm making in the execution of this script. Is the logic in the original script sound? If so, have I modified it in some way that would lead to it not functioning properly?

UPDATE: I recently read another post here that gave me some insight about symlinks on external drives. Having a link to the most recent backup isn't essential, since I have other ways of finding out which backup is the most recent.

  • If I recall correctly, the drive's formatted as FAT32. According to the post I linked, FAT32 seems to have unix-style permissions/symlink issues. – alyms108 Jan 3 '17 at 10:51
0

You can take a look at rsnapshot, which does exactly what you need (albeith using snapshots rather than incremental backups).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.