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

Backup of / is not cron friendly

Open prontog opened this issue 4 years ago • 6 comments

Hello and thanks for this very useful tool!

When you backup /, the SRC_FOLDER var is stripped of the last / (line 378), and the df call (line 411) writes "df: '': No such file or directory" to STDERR. The script continues with the backup but it is not cron friendly since it always writes to STDERR and you cannot do:

[email protected] 0 */1 * * * rsync_tmbackup.sh / /mnt/backup >/dev/null

and only expect emails when something unexpected happens. It will always send an email due to the df error.

Best regards,

Panos

prontog avatar Nov 11 '19 16:11 prontog

definitely a bug introduced by #170

kapitainsky avatar Nov 11 '19 17:11 kapitainsky

@kapitainsky, thanks for the quick response!

After adding a check so that it only strips when [[ $SRC_PATH != / ]], I stumbled on another cron unfriendliness :)

rsync_tmbackup.sh [email protected]:/home/panos /mnt/backup_drive >/dev/null

will always write "Warning: Permanently added 'blah blah blah" (RSA) to the list of known hosts."

This is most likely because of the -o UserKnownHostsFile=/dev/null in lines 549, 551.

Wouldn't it be easier and more flexible to leave the ssh config to the user (with the -e option of rsync)?

The same goes for the necessary user part when parsing the SRC_FOLDERS and DEST_FOLDER in lines 177 and 188. I bet many users will set the user in their ~/.ssh/config file. I think simply splitting on the : is enough.

Should I make a PR? I could also add tests.

Best regards,

Panos

prontog avatar Nov 12 '19 10:11 prontog

You should definitely create PR and explain all details. I am sure @laurent22 will consider including it.

kapitainsky avatar Nov 12 '19 10:11 kapitainsky

FYI this issue is caused by https://github.com/laurent22/rsync-time-backup/blob/88db869fe7a52864e18afc7e16a971499f79e830/rsync_tmbackup.sh#L359 and https://github.com/laurent22/rsync-time-backup/blob/88db869fe7a52864e18afc7e16a971499f79e830/rsync_tmbackup.sh#L378

reactive-firewall avatar Mar 19 '20 03:03 reactive-firewall

#184 looks to be a possible fix for the / issue discussed here, but I wonder if fixing the issue when parsing args might be safer and easier to maintain 🤔 ... thoughts?

reactive-firewall avatar Mar 19 '20 03:03 reactive-firewall

This sounds like the best approach. Normalize the arguments at the start.

prontog avatar Mar 19 '20 12:03 prontog