1
I'm having a bit of a problem with cronjobs for backups.
I've set up the following in sudo crontab -e
(not under personal account):
0 1 * * * /backups/dobackup
/backups/dobackup
contains this:
#!/bin/sh
touch ITRAN
tar -cvpjf /backups/$(date +%d.%m.%Y)_backup.tar.bz2 --exclude=/backups --exclude=/proc --exclude=/lost+found --exclude=/sys --exclude=/mnt --exclude=/media --exclude=/dev /
The backup file is created, but the file ITRAN is not. Also, the backup file is vastly smaller than expected:
-rw-r--r-- 1 rjrudman root 371620259 2012-06-21 12:39 21.06.2012_backup.tar.bz2
-rw-r--r-- 1 rjrudman root 1023211449 2012-06-22 18:00 22.06.2012_backup.tar.bz2
-rw-r--r-- 1 rjrudman root 1512785 2012-06-23 01:00 23.06.2012_backup.tar.bz2
-rw-r--r-- 1 rjrudman root 1023272455 2012-06-24 22:41 24.06.2012_backup.tar.bz2
-rw-r--r-- 1 rjrudman root 1514027 2012-06-25 01:00 25.06.2012_backup.tar.bz2
The backups with much larger file sizes are created by manually running sudo /backups/dobackup
. It seems the cronjob is failing at some point.. but I have no idea how to debug this issue or where to start.
Any ideas? Running ubuntu 10.04
1You can always redirect stdout & stderr to find out if tar fails, as well as the value of
pwd
to see where ITRAN is created. – mlt – 2012-06-24T23:57:45.440@mlt Cheers, I'll give it a go and have a look next time it runs – Rob – 2012-06-25T00:20:42.640
BTW, instead of using
crontab -e
you could place a file in/etc/cron.d/
, the file format is slightly different and allows you to set the username you want. See the existing files in that directory for examples. – Zoredache – 2012-06-25T01:04:23.463