Hi!
Maybe i am here in the wrong section for the problem, but let me try to explain. I have the following simple backup script, as a solution till the final backup solution is online. Unfortunatly it will only work when executed manually. When i set up a cron job to execute the script, only the mysql service is stopped and restarted. There is no backup after the cron job, either executed as normal user or root.
Where is my mistake?
#!/bin/sh
archive1="/adm/backup/files/dfs_full_backup_`date +%d-%m-%y`.tar.gz"
archive2="/adm/backup/files/dfs_diff_backup_`date +%d-%m-%y`.tar.gz"
file="/adm/backup/filelist"
wochentag="`date +%a`"
if [ $wochentag == "So" ]; then
# Fullbackup
timestamp="`/bin/date +%Y-%m-%d\ %H:%M:%S`";echo $timestamp > /adm/backup/.lastfullbackup
sudo /etc/init.d/mysql stop
sudo /bin/tar -czPf $archive1 -T $file > /adm/backup/log/log`/bin/date +%Y%m%d`
sudo /etc/init.d/mysql start
scp -i /home/admin/.ssh/id_dsa $archive1 admin@xx-xxxx-xxxx.xx.xxx.xxx:$archive1
find /adm/backup/files/* -mtime +14 | xargs rm -f
else
#Differenzbackup
sudo /etc/init.d/mysql stop
sudo /bin/tar -chvzPf $archive2 --newer=".lastfullbackup" -T $file > /adm/backup/log/log`/bin/date +%Y%m%d`
sudo /etc/init.d/mysql start
scp -i /home/admin/.ssh/id_dsa $archive2 admin@xx-xxxx-xxxxx.xx.xxx.xxx:$archive2
find /adm/backup/files/* -mtime +14 | xargs rm -f
fi
exit 0
cat /adm/backup/filelist
/var/lib/mysql
/srv/www/htdocs
