4

I am creating a bash script to backup my files with rsync.

Backups all come from a single directory. I only want new or modified files to be backed up.

Currently, I am telling rsync to backup the dir, and to check the files compared to the last backup.

The way I am doing this is

THE_TIME=`date "+%Y-%m-%dT%H:%M:%S"`
rsync -aP --link-dest=/Backup/Current /usr/home/user/backup /Backup/Backup-$THE_TIME
rm -f /Backup/Current
ln -s /Backup/Backup-$THE_TIME /Backup/Current

I am pretty sure I have the syntax correct for this. Each backup will check against the "Current" folder, and upload only as necesary. It will then delete the Current folder, and re-create the symlink to the newest backup it just did.

I am getting an error when I run the script:

rsync: link "/Backup/Backup-2010-08-04-12:21:15/dgs1200series_manual_310.pdf"

=> /Backup/Current/dgs1200series_manual_310.pdf failed: Operation not supported (45)

The host OS is running HFS filesystem, which supports hard linking. I am trying to figure out if something else is not supporting this, or if I have a problem in my code.

Thanks for any help

Edit:

I am able to create a hard link on my local machine. I am also able to create a hard link on the remote server (when logged in locally) I am NOT able to create a hard link on the remote server when mounted via afp. Even if both files exist on the server.

I am guessing this is a limitation of afp.

David Houde
  • 4,835
  • 1
  • 20
  • 29
  • I've got the same error, "rsync: link [...] Operation not supported (45)" because the target filesystem (local) don't support hard link (ExFAT) – mems Jun 20 '23 at 11:52

3 Answers3

3

Just in case your command line is only an example: Be sure to always specify the link-dest directory with an absolute pathname! That’s something which took me quite some time to figure out …

christoph
  • 173
  • 8
  • This is weird. For some reason, specifying target as ./myfile didn't work but /Users/dankle/myfile did work... Anyway, it worked so +1 :) – Daniel Nov 09 '11 at 20:09
  • 1
    @Daniel, it would works with a relative paths, but the trick is that it needs to be relative to the *destination* directory. So in your case, it might be something like "../myfile". – laurent Nov 05 '13 at 06:45
1

Two things from the man page stand out that are worth checking:

If file's aren't linking, double-check their attributes. Also check if some attributes are getting forced outside of rsync's control, such a mount option that squishes root to a single user, or mounts a removable drive with generic ownership (such as OS X's “Ignore ownership on this volume” option).

and

Note that rsync versions prior to 2.6.1 had a bug that could prevent --link-dest from working properly for a non-super-user when -o was specified (or implied by -a). You can work-around this bug by avoiding the -o option when sending to an old rsync.

Do you have the "ignore ownership" option turned on? What version of rsync do you have?

Also, have you tried manually creating a similar hardlink using ln at the command line?

Dennis Williamson
  • 346,391
  • 90
  • 374
  • 439
1

I don't know if this is the same issue, but I know that rsync can't sync a file when the destination is a FAT32 partition and the filename has a ":" (colon) in it. [The source filesystem is ext3, and the destination is FAT32]

Try reconfiguring the date command so that it doesn't use a colon and see if that makes a difference.

e.g.

THE_TIME=`date "+%Y-%m-%dT%H_%_%S"`
Menachem
  • 173
  • 8