JRehkemper.de

Restore Crontab From Backup

Restore from Filesystem Backup

If you deleted your Crontab for example with crontab -r but have full filesystem backup you can restore it by recovering /var/spool/cron/<your-user>.

After that you can reload it into your active Crontab by executing

crontab </path/to/restored/crontab/file>

Restore from Syslog

If you don’t have a backup you best chance is to have a look at /var/log/cron.
There you will find all the Commands executed and based on the timestamps you can reverse-engineer the cron-expression.
Not the best solution, but better than nothing.

Backing Up you Crontab

The easiest way to backup your crontab is create a file with the output of crontab -l and save it somewhere else than your server.

crontab -l > crontab-backup.txt

That way it will not get overwritten by some OS-Jobs.

profile picture of the author

Jannik Rehkemper

I'm an professional Linux Administrator and Hobby Programmer. My training as an IT-Professional started in 2019 and ended in 2022. Since 2023 I'm working as an Linux Administrator.