Here’s the setup: Synology Diskstation NAS, which uses DSM, their Linux-based customized system. My task is to backup, fully then incrementally, a number of file system shares on the Diskstation to an external disk drive mounted directly using USB. When mounted, the drive is treated like a new share.
(You can read the text of the script here since it might help to see it all).
The script calls rsync to do the backups. The plan calls for the script to start with a full backup. When done, a symlik will be created to point to the last backup location (“latest”). On subsequent incremental runs, the –link-dest flag points to the “latest” location. Rsync should create hardlinks for existing files and copy over new ones. The old symlink is removed and replaced after the new event finishes. The script is run directly on the NAS.
Here’s an example of the command used to fire it off:
rsync --archive --progress --verbose --human-readable /
--exclude '@eaDir' -f'- #recycle/' -f'- .Trash**' /
-f'- *cache/' -f '- ./cache' -f'- *git/' /
--log-file="${LOG_FILE}" --link-dest $LAST
"$p" "${BPATH}/${SOURCE}"
This initial backup doesn’t include the “–link-dest $LAST” option, only the incrementals. All the variables are set in advance (I have tested using echos to make sure they are formatted correctly). The “$p” variable is the name of the specific share directory in “dirname/” format so it copies the entire directory. The exclude and the filters are set like this because of some issues getting them to work…these work.
The problem I’m having is that the script runs fine, I see no errors and I get some output to see that things are OK. When it’s done, the new directories have all been created, the symlink is created and added, but none of the files – nothing – are actually copied over to the external drive.
This is a small section of the output I get:
~/scripts $ sudo ./backup_final.sh
Password:
Backup drive one or two? two
current backup directory not found, creating...
/volumeUSB1/usbshare/2024-09-30_19:52:17
sending incremental file list
drwxr-xr-x 4.10K 2024/09/30 19:52:17 .
sent 39 bytes received 64 bytes 68.67 bytes/sec
total size is 0 speedup is 0.00
sending incremental file list
drwxr-xr-x 4.10K 2024/09/30 19:52:17 .
sent 39 bytes received 64 bytes 206.00 bytes/sec
total size is 0 speedup is 0.00
sending incremental file list
drwxr-xr-x 4.10K 2024/09/30 19:52:17 .
sent 39 bytes received 64 bytes 206.00 bytes/sec
total size is 0 speedup is 0.00
sending incremental file list
drwxr-xr-x 4.10K 2024/09/30 19:52:17 .
As you can see, the file lists are being created, but not a thing is copied over.
The external drive is, at this moment, empty when I run this, so this is a clean first-time attempt. I even tried silly stuff like unmounting and remounting it, just in case.
The maddening thing is that when I was playing around with this a few weeks ago, I was able to get it working at least once. Now it does nothing.
I would would appreciate different eyes looking at this to see if I’m doing something wromg. Apologize for the tl;dr.