0

I created a backup-shell that runs as a cron job. That's not new.... But in the command line I have the logfilename specified with a date format. All is ok, until it reaches the folder where the logfile resides. It creates a folder witha that name and it looks like rsync is copying everything in that folder, including the strange foldername, over and over again. I try to rsync to my synology where DSM 6.1 is installed. I shared a folder on the synology to /mnt/NAS2 on my server The script is

/root/backup/backup_daily.sh

it is set to run once a day. the command line in the script is basically:

rsync -avzr --stats --progress --log-file=$(date +'%Y%m%d') --exclude-from=$EXCLUDE / /mnt/NAS2/backup

(I use some vars for the options, but for clarity replaced by the strings. I have tried to do in the script as well, does not make any difference.) In the exclude file are some folders, including /root/backup/

Here is what happens, see after the file 'xx':

2017/04/03 20:51:09 [1669] >f+++++++++ lib/xtables/libxt_time.so

2017/04/03 20:51:09 [1669] >f+++++++++ lib/xtables/libxt_tos.so

2017/04/03 20:51:09 [1669] >f+++++++++ lib/xtables/libxt_u32.so

2017/04/03 20:51:09 [1669] >f+++++++++ lib/xtables/libxt_udp.so

2017/04/03 20:51:09 [1669] cd+++++++++ lib64/

2017/04/03 20:51:09 [1669] cL+++++++++ lib64/ld-linux-x86-64.so.2 -> /lib/x86_64 -linux-gnu/ld-2.23.so

2017/04/03 20:51:09 [1669] cd+++++++++ opt/

2017/04/03 20:51:09 [1669] cd+++++++++ root/

2017/04/03 20:51:09 [1669] >f+++++++++ root/.bash_history

2017/04/03 20:51:09 [1669] >f+++++++++ root/.bashrc

2017/04/03 20:51:09 [1669] >f+++++++++ root/.profile

2017/04/03 20:51:09 [1669] >f+++++++++ root/.selected_editor

2017/04/03 20:51:09 [1669] >f+++++++++ root/20170403

2017/04/03 20:51:09 [1669] >f+++++++++ root/xx

2017/04/03 20:51:09 [1669] cd+++++++++ root/+"%Y%m%d").log/

2017/04/03 20:51:09 [1669] cL+++++++++ root/+"%Y%m%d").log/initrd.img -> boot/in itrd.img-4.4.0-71-generic

2017/04/03 20:51:09 [1669] cL+++++++++ root/+"%Y%m%d").log/initrd.img.old -> boo t/initrd.img-4.4.0-70-generic

2017/04/03 20:51:09 [1669] cL+++++++++ root/+"%Y%m%d").log/vmlinuz -> boot/vmlin uz-4.4.0-71-generic

[This goes on and on.]

I must do something obviously thing wrong... Hope I supplied enough info and did use the correct rules/indents, as it is first post on this forum.

0

What if you run your command directly as you posted it here from the terminal?

Did you try, to set --log-file to a static value? Because for me it looks like at the root/+"%Y%m%d").log/vmlinuz part something went wrong. Do you have somewhere else in your script a definition of the date like "%Y%m%d"?

1
  • Well, the issue is that when I tried those things, I initially did not notice that the 'recursive tree' was created inside the /root/backup folder. I thought it was only created in the target folder. After I found out it was actually backing up an existing structure (Due to some error in an earlier stage), I started over again after pruning the tree. And if I remember well, replacing " with ' did the trick, while I do not see why. So long story short, the issue is solved and I do not have the time to try to regenerate it again. Thanks for suggestions. – Rene NL Apr 16 '17 at 20:44
0

Thanks. If I start the script manually, same behavior. I expect that if I fix the logfilename, it will not happen. I do not use the date elsewhere, I only use it once in the script to set the variable. As I mentioned, for simplicity I put that part on the commandline. The script is very short. In this version I put the date on the commandline, but initially I used the CURDATE - no difference.

#!/bin/bash
#
# Backup (Incremental) of server
#
LOCALDIR=/
SERVERDIR=/mnt/NAS2/backup
EXCLUDE='/root/backup/exclude.lst'
CURDATE="$(date +'%Y%m%d')"
LOGFILE="/root/backup/$CURDATE.log"

rsync -avzr --stats  \
 --progress --log-file=$(date +'%Y%m%d') \
 --exclude-from=$EXCLUDE $LOCALDIR $SERVERDIR

It goes wrong exactly after backing up the file /root/xx, and that is exactly the point where the logfile is created. So I guess it goes wrong because it tries to backup the logfile that it is writing to. For that reason I tried to exclude the backup folder, but that seems to be ignored. I found some discussion about the exclude file, but maybe I misinterpred that, as it still tries to backup that folder.

Exclude.lst, just for reference:

lost+found
down
/tmp
.cache
.thumbnails
/dev
/media
/mnt
/proc
/sys
/root/backup/

Note: it is a test server, not on the net, just to test scripts before I use it on a live server:). BTW - using rsync with ssh to the synology seems a better option than backing up to a shared folder, but even after copying the key, using ssh-copy-id, the synology keeps asking for password, so that is another challange. Thanks again for your help.

2
  • are you sure, you dont have a folder called +"%Y%m%d? The cd+++++++++ root/+"%Y%m%d").log/ part looks like rsync is syncing a folder then followed by some links to /boot – chloesoe Apr 15 '17 at 18:30
  • You are right, that folder does exits, but was created recursively during the backup. In that folder was the complete tree, including another folder with that name. It took quite some time to delete the complete tree (More a forest) under that. No clue why, but after I deleted it and excluded tne folder form backup it looks like it is OK. (Altough I still have the issue that I can't logon without entering password, while all looks ready for that, but that is for a separate threat at some time. Thank for replying, even after so long. – Rene NL Apr 16 '17 at 19:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.