rsync-time-backup icon indicating copy to clipboard operation
rsync-time-backup copied to clipboard

Empty folder when network share is unavailable

Open psmanek opened this issue 6 years ago • 6 comments

Hi,

If network share is unavailable script create new empty dated folder. What network folder becomes available again backup starts from the beginning, because previous folder is empty.

Maybe it should make things it different order :) First check connection, then start to backup.

Thanks, Pawel

psmanek avatar Sep 07 '17 09:09 psmanek

I can confirm something similar (and probably related). Occasionally, the script starts a complete back-up from scratch, and when I investigate, I always find that, indeed, the previous backup folder is empty. I doubt that the script can create an empty folder when there is no network drive though; my guess is, at least in my case, that I just happen to switch off or reboot my server when the script is going through it first phase (after creating the folder). Not sure much can be done about this, unless the script knows to disregard an empty folder.

jurgihub avatar Sep 07 '17 09:09 jurgihub

Are you using the latest version of the script? Because there was a recent bug that could result in empty directories being left on the backup drive (I had the issue too), but that should be fixed in the latest version.

Normally, a marker is left on the drive if a backup hasn't been completed so the script should know and resume from that empty directory (not create a new directory based on that empty one).

laurent22 avatar Sep 07 '17 10:09 laurent22

Yes, i'm using latest version. It create new empty dated folder and there is no .inprogress file.

terminal output:

rsync_tmbackup: Previous backup found - doing incremental backup from /Volumes/externaldrive/Backup/2017-09-07-114620 rsync_tmbackup: Creating destination /Volumes/externaldrive/Backup/2017-09-07-121256 rsync_tmbackup: Starting backup... rsync_tmbackup: From: /Volumes/networkshare/projects/ rsync_tmbackup: To: /Volumes/externaldrive/Backup/2017-09-07-121256/ rsync_tmbackup: Running command: rsync_tmbackup: rsync -D --compress --numeric-ids --links --hard-links --one-file-system --itemize-changes --times --recursive --perms --owner --group --stats --human-readable --log-file '/Users/user/logs/2017-09-07-121256.log' --link-dest='/Volumes/externaldrive/Backup/2017-09-07-114620' -- '/Volumes/networkshare/projects/' '/Volumes/externaldrive/Backup/2017-09-07-121256/' rsync: link_stat "/Volumes/networkshare/projects/." failed: No such file or directory (2)

Number of files: 0 Number of files transferred: 0 Total file size: 0 bytes Total transferred file size: 0 bytes Literal data: 0 bytes Matched data: 0 bytes File list size: 5 File list generation time: 0.001 seconds File list transfer time: 0.000 seconds Total bytes sent: 21 Total bytes received: 20

sent 21 bytes received 20 bytes 82.00 bytes/sec total size is 0 speedup is 0.00 rsync error: some files could not be transferred (code 23) at /BuildRoot/Library/Caches/com.apple.xbs/Sources/rsync/rsync-51/rsync/main.c(996) [sender=2.6.9] rsync_tmbackup: [ERROR] Rsync reported an error. Run this command for more details: grep -E 'rsync:|rsync error:' '/Users/user/logs/2017-09-07-121256.log'

psmanek avatar Sep 07 '17 10:09 psmanek

I've not tested it, but a solution could look like this:

if ! fn_run_cmd "[ -r $SRC_FOLDER ]"; then
    fn_log_error "failed to read the source folder: ${SRC_FOLDER}"
    exit 2
fi

thomas-mc-work avatar Nov 28 '17 08:11 thomas-mc-work

Having a similar issue; i'm using rsync tmbackup over ssh to backup remote hosts. If the host is down once during a backup, rsync_tmbackup will create an empty folder nonetheless, and update the latest symbolic link to point to this empty folder. Should i file a separate bug for this ?

fthiery avatar Dec 20 '17 10:12 fthiery

Change the end of the script to the following to prevent empty folders in these cases.

    # -----------------------------------------------------------------------------
    # Add symlink to last backup if folder is not empty
    # -----------------------------------------------------------------------------
    if [ "$(ls -A "$DEST_FOLDER/$(basename -- "$DEST")")" ]; then
        fn_rm_file "$DEST_FOLDER/latest"
        fn_ln "$(basename -- "$DEST")" "$DEST_FOLDER/latest"
    else
        fn_rm_dir "$DEST_FOLDER/$(basename -- "$DEST")"
    fi
    fn_rm_file "$INPROGRESS_FILE"

    exit $EXIT_CODE

EDIT 8/2/2020: Needed a couple changes.

markalston avatar Jul 27 '20 19:07 markalston