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

Can't find existing backups on remote w/ restricted shell

Open zenspider opened this issue 4 years ago • 1 comments

I just ran and finished a backup. To test, I ran it a second time:

root@lust:~# ./rsync_tmbackup.sh -i .ssh/rsync.net.pub / 4295@rsync:backups/lust rsync-exclude.txt
df: '': No such file or directory
find: |: unknown primary or operator
rsync_tmbackup: No previous backup - creating new one.
rsync_tmbackup: Creating destination 4295@rsync:backups/lust/2020-04-03-015139
find: |: unknown primary or operator
find: |: unknown primary or operator
rsync_tmbackup: Starting backup...
rsync_tmbackup: From: /
rsync_tmbackup: To:   4295@rsync:backups/lust/2020-04-03-015139/
rsync_tmbackup: Running command:
rsync_tmbackup: rsync  -e 'ssh -p 22 -i .ssh/rsync.net.pub -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null' -D --numeric-ids --links --hard-links --one-file-system --itemize-changes --times --recursive --perms --owner --group --stats --human-readable --compress --log-file '/root/.rsync_tmbackup/2020-04-03-015140.log' --exclude-from 'rsync-exclude.txt'  -- '/' '4295@rsync:backups/lust/2020-04-03-015139/'
Warning: Output redirection not supported
Warning: Output redirection not supported
32751 > backups/lust/backup.inprogress
.d..t...... ./
cL+++++++++ initrd.img -> boot/initrd.img-4.15.0-91-generic
cL+++++++++ initrd.img.old -> boot/initrd.img-4.15.0-88-generic
cL+++++++++ vmlinuz -> boot/vmlinuz-4.15.0-91-generic
cL+++++++++ vmlinuz.old -> boot/vmlinuz-4.15.0-88-generic
cd+++++++++ etc/
<f+++++++++ etc/.pwd.lock
<f+++++++++ etc/adduser.conf
...

rsync.net has a restricted shell on the other side and apparently the df command isn't available. But at the very least, the exit code is coming back 1 and can be checked.

Found some more:

DEST="$DEST_FOLDER/$NOW"
+ DEST=backups/lust/2020-04-03-020453
PREVIOUS_DEST="$(fn_find_backups | head -n 1)"
++ head -n 1
++ fn_find_backups
++ fn_run_cmd 'find backups/lust/ -maxdepth 1 -type d -name "????-??-??-??????" -prune | sort -r'
++ '[' -n 4295@rsync: ']'
++ eval 'ssh -p 22 -i .ssh/rsync.net.pub 4295@rsync '\''find backups/lust/ -maxdepth 1 -type d -name "????-??-??-??????" -prune | sort -r'\'''
+++ ssh -p 22 -i .ssh/rsync.net.pub 4295@rsync 'find backups/lust/ -maxdepth 1 -type d -name "????-??-??-??????" -prune | sort -r'
find: |: unknown primary or operator

This is because you're sorting on the other side and the other side doesn't allow pipes. There's no need for that sort to be on the other side tho. Indeed, I just verified that if I pull the sort out of the ssh command, then it finds the latest backup.

Still doesn't find or create the inprogress link, so it is not continuing from the previously interrupted. Ah. Yes:

ssh -p 22 -i .ssh/rsync.net.pub 4295@rsync 'echo 489 > backups/lust/backup.inprogress'
++ ssh -p 22 -i .ssh/rsync.net.pub 4295@rsync 'echo 489 > backups/lust/backup.inprogress'
Warning: Output redirection not supported
Warning: Output redirection not supported
489 > backups/lust/backup.inprogress

So, at this point, I'm guessing there are some things that can be changed to make it work a little more robustly (eg checking exit codes, doing minimal work on the remote side, etc), but I'm guessing this project just isn't a fit for rsync.net's restrictions.

P.S. Your Readme's TODO list is stale, considering the first bit that is failing is that FAT FS checker.

zenspider avatar Apr 03 '20 09:04 zenspider

🤔 this seems closely related to #195

reactive-firewall avatar Apr 04 '20 00:04 reactive-firewall