25

I want to do a complete server backup.

I already have my backup script copying all of the html/php files for the web app, and the mysql databases, placing them into a .tar.gz file.

How can I add the crontab files to that backup?

Whenever I save the crontab, it goes to /tmp folder.. and when I check that folder immediately afterwards, it is empty.

35

You could just backup the entire /var/spool/cron directory. It contains all crontabs of all users.

14

You can periodically run crontab -l > my_crontab.backup to backup the crontab into file.

8

just backup the file /var/spool/cron/USER_NAME

  • 1
    For Ubuntu 14.04 at least, the relevant files are in the directory /var/spool/cron/crontabs. – Kenny Evitt Jan 22 '15 at 1:31
  • @KennyEvitt and you must be the root to access it sudo -i – NineCattoRules Apr 23 '16 at 9:43
3

I made my backup into a cron job.

0 9 * * * crontab -l | gzip > /backups/'crontab-'$(date +"\%Y\%m\%d-\%H\%M\%S")'.gz'

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.