1

CRONTABS

I'm using rsnapshot with cron. Here's what sudo crontab -l shows me.

0 */4           * * *   /usr/bin/rsnapshot hourly
30 3    * * *           /usr/bin/rsnapshot daily
0  3    * * 1           /usr/bin/rsnapshot weekly

OUTPUT

I went to check on the backup folder to see if everything is working correctly, but here is the time sorted output:

elijah@degas:~$ ls -lt /media/backup/
total 0
drwxrwxrwx 1 root root 0 May 30 04:00 hourly.1
drwxrwxrwx 1 root root 0 May 23 04:00 hourly.2
drwxrwxrwx 1 root root 0 May 17 04:00 hourly.3
drwxrwxrwx 1 root root 0 May 14 04:00 hourly.4
drwxrwxrwx 1 root root 0 May 13 04:00 hourly.5
drwxrwxrwx 1 root root 0 May 12 04:00 daily.0
drwxrwxrwx 1 root root 0 May 10 04:00 daily.1
drwxrwxrwx 1 root root 0 May  7 04:00 daily.2
drwxrwxrwx 1 root root 0 May  4 04:00 daily.3
drwxrwxrwx 1 root root 0 Apr 29 16:00 daily.4
drwxrwxrwx 1 root root 0 Apr 28 20:00 daily.5
drwxrwxrwx 1 root root 0 Apr 28 16:04 hourly.0
drwxrwxrwx 1 root root 0 Apr 28 12:21 daily.6
drwxrwxrwx 1 root root 0 Apr 27 10:09 weekly.1
drwxrwxrwx 1 root root 0 Apr 25 07:23 weekly.3

The output seems almost random! Why could this be happening? I have what I thought was an identical configuration on a different machine, and it seems to be working fine.

SYSLOG

elijah@degas:~$ cat /var/log/syslog.1 | grep cron
Jun 20 07:40:21 degas anacron[2795]: Job `cron.daily' terminated
Jun 20 07:40:21 degas anacron[2795]: Normal exit (1 job run)
Jun 20 08:17:01 degas CRON[3144]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Jun 20 09:17:01 degas CRON[3228]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Jun 20 10:17:01 degas CRON[4893]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Jun 20 11:17:01 degas CRON[8737]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Jun 20 12:17:01 degas CRON[10192]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Jun 20 13:17:01 degas CRON[11870]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Jun 20 14:17:01 degas CRON[12829]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Jun 20 15:17:01 degas CRON[13614]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Jun 20 15:54:28 degas crontab[14446]: (root) BEGIN EDIT (root)
Jun 20 15:55:27 degas crontab[14446]: (root) END EDIT (root)
Jun 20 15:55:29 degas crontab[14460]: (root) LIST (root)
Jun 20 16:17:01 degas CRON[14770]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Jun 20 16:44:04 degas crontab[14911]: (root) DELETE (root)
Jun 20 16:44:07 degas crontab[14913]: (root) LIST (root)
Jun 20 17:17:01 degas CRON[15713]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Jun 20 18:17:01 degas CRON[15842]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Jun 20 19:17:01 degas CRON[15928]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Jun 20 20:17:01 degas CRON[16023]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Jun 20 21:17:01 degas CRON[16110]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Jun 20 22:17:01 degas CRON[16212]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Jun 20 23:17:01 degas CRON[16300]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Jun 21 00:00:01 degas CRON[16372]: (root) CMD (invoke-rc.d atop _cron)
Jun 21 00:17:01 degas CRON[16437]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Jun 21 01:17:01 degas CRON[16525]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Jun 21 02:17:01 degas CRON[16612]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Jun 21 03:17:01 degas CRON[16701]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Jun 21 04:17:01 degas CRON[16798]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Jun 21 05:17:01 degas CRON[16886]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Jun 21 06:17:01 degas CRON[16974]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Jun 21 06:25:01 degas CRON[16988]: (root) CMD (test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily ))
Jun 21 07:17:01 degas CRON[17061]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Jun 21 07:30:01 degas CRON[17083]: (root) CMD (start -q anacron || :)
Jun 21 07:30:01 degas anacron[17086]: Anacron 2.3 started on 2016-06-21
Jun 21 07:30:01 degas anacron[17086]: Will run job `cron.daily' in 5 min.
Jun 21 07:30:01 degas anacron[17086]: Jobs will be executed sequentially
Jun 21 07:35:01 degas anacron[17086]: Job `cron.daily' started
Jun 21 07:35:01 degas anacron[17099]: Updated timestamp for job `cron.daily' to 2016-06-21

RSNAPSHOT TEST

elijah@degas:~$ /usr/bin/rsnapshot -t hourly
echo 23633 > /var/run/rsnapshot.pid 
/bin/rm -rf /media/backup/hourly.5/ 
mv /media/backup/hourly.4/ /media/backup/hourly.5/ 
mv /media/backup/hourly.3/ /media/backup/hourly.4/ 
mv /media/backup/hourly.2/ /media/backup/hourly.3/ 
mv /media/backup/hourly.1/ /media/backup/hourly.2/ 
/bin/cp -al /media/backup/hourly.0 /media/backup/hourly.1 
/usr/bin/rsync -a --delete --numeric-ids --relative --delete-excluded \
    --exclude=/var/ --exclude=/space/ --exclude=/nfs/ --exclude=/media/ \
    --exclude=/proc/ --exclude=/sys/ --exclude=/dev/ --exclude=/tmp/ \
    --exclude=/cdrom/ --exclude=media/backup /. \
    /media/backup/hourly.0/Backup 
touch /media/backup/hourly.0/ 
  • is crond still alive? – meuh Jun 20 '16 at 21:12
  • How can I check? I did sudo ps aux | grep crond and got elijah 3795 0.0 0.0 9388 952 pts/10 S+ 16:46 0:00 grep --color=auto crond which I think is just the grep command I ran.... – Elijah Jun 20 '16 at 21:46
  • Your ps|grep command is correct, so perhaps cron got killed, eg because you ran out of memory. Look through the logs in /var/log/ depending on your system. – meuh Jun 20 '16 at 21:54
  • found some info in /var/log/syslog.1, you can see where I removed the crontab for root yesterday, as per roaima – Elijah Jun 21 '16 at 15:04
1

After some extended discussion it appears that the filesystem may corrupted. As an example, rm -rf fails - as root - on a normal tree of files.

After unmounting the filesystem, fsck identified it as NTFS.

Frustratingly I have seen NTFS fail on other Linux-based platforms under the heavy loads incurred from rsnapshot. There's nothing sufficiently repeatable with which a bug can be filed, but a week's worth of rsnapshots can usually corrupt the filesystem.

My recommendation is to replace the NTFS filesystem with something native to a Linux-based system, such as ext4. As an aside, if the backups must be accessed from a Windows platform, I have had good use from the Ext2FSD utility and driver for extN filesystems (also at sourceforge).

4

This original advice applies only to Debian-based distributions:

The two crontab segments you've shown are not the same crontab. So your jobs are running twice (once from /etc/cron.d/rsnapshot and once from crontab -l).

Remove one set, for example with sudo crontab -r, and it'll start working properly.


The next suggestion is to ensure that sync_first is not set in the /etc/rsnapshot.conf file. (Or if it is, that it's 0.) Otherwise although the cycling of rsnapshot directories will occur, no backup will actually get taken without an explicit rsnapshot sync command.

  • executed sudo crontab -r yesterday, but still haven't seen any action this morning. edited question to include syslog – Elijah Jun 21 '16 at 15:05
  • OK. Interesting discovery (on my part) is that /etc/cron.d is a Debian extension and apparently not supported by other distributions. @Elijah, since you appear not to be using Debian please can you add back root's crontab and (for sake of form) comment out the entries in your /etc/cron.d/rsnapshot – roaima Jun 21 '16 at 16:05
  • @Elijah please can you confirm that in your /etc/rsnapshot.conf you do not have sync_first 1 configured. – roaima Jun 21 '16 at 16:07
  • sync_first is commented out completely – Elijah Jun 21 '16 at 16:49
  • also just to clarify, the machine in question is running ubuntu 14.04 – Elijah Jun 21 '16 at 18:08

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.