Problem rsync, deletes all files target after first succesfull backup
Hi there,
I have the follwoing issue:
I use the following script file backup.sh:
#!/bin/sh
if [ -f "/media/backups/mounted" ]
then
rsync -rlptgo --delete --delete-excluded --exclude=**~ --exclude=**/*cache*/ --exclude=**/*Cache*/ --exclude=**/*trash*/ ~/ /media/backups/current/ --exclude=.* --log-file="/home/<user name>/Logfiles/rsync.log.$(date +%Y%m%d%H%m%S)" --verbose --update --itemize-changes
else
kdialog --title "Backup Failed" --passivepopup "Please connect hard drive and back up your data ASAP!" 3600 &
fi
When I execute the backup.sh from the terminal the first time every file will be copied to the target. I don't use sudo.
This is a subset of the log file:
2014/03/07 09:16:33 [2854] >f+++++++++ Secret of Nikola Tesla - The Movie (Tajna Nikole Tesle) (1980).avi
2014/03/07 09:16:33 [2854] >f+++++++++ backup.sh
2014/03/07 09:16:33 [2854] cd+++++++++ Desktop/
2014/03/07 09:16:37 [2854] >f+++++++++ Desktop/book.zip
Via "crontab -e", on 21:00 the backup is started automatically.
0 21 * * * /home/USERNAME/backup.sh
The second logfile looks like this:
2014/03/07 21:00:02 [5888] building file list
2014/03/07 21:00:02 [5889] building file list
2014/03/07 21:00:02 [5888] .d..tpog... ./
2014/03/07 21:00:02 [5888] *deleting tmp/simple/util.h
2014/03/07 21:00:02 [5888] *deleting Pictures/Selection_035.png
2014/03/07 21:00:02 [5888] *deleting Pictures/Selection_034.png
2014/03/07 21:00:02 [5888] *deleting Pictures/Selection_033.png
2014/03/07 21:00:02 [5888] *deleting Pictures/Selection_032.png
2014/03/07 21:00:02 [5888] *deleting Pictures/Selection_031.png
2014/03/07 21:00:02 [5888] *deleting Pictures/Selection_030.png
Somewhere in the middle of the logfile:
2014/03/07 21:00:06 [5889] rsync: recv_generator: mkdir "/media/backups/current/Downloads" failed: Permission denied (13)
2014/03/07 21:00:06 [5889] *** Skipping any contents from this failed directory ***
2014/03/07 21:00:06 [5889] cd+++++++++ Logfiles/
2014/03/07 21:00:06 [5889] rsync: recv_generator: mkdir "/media/backups/current/Logfiles" failed: Permission denied (13)
2014/03/07 21:00:06 [5889] *** Skipping any contents from this failed directory ***
2014/03/07 21:00:06 [5889] cd+++++++++ Music/
2
The result of all that is that the target directory is empty, everything has been deleted.
I changed the ownership of /media/backups/current before the auto backup to my user name and group. After the auto backup it seems to be root:root again???
What is wrong and why is the ownership changed?
PS I am relative new to Linux.
Regards
|