Backups and Cron

I’m making my backups more automated. I decided to use the simple backup tool that can be found under System -> Administration, but I configured it exactly how I had mondo configured, as far as which directories to back up and which to ignore. One tricky thing was, by default it wants to back stuff up to /var/backup. I wanted it to back stuff up to my other hard drive found at /mnt/home. The GUI has a place to set that, but it seemed to ignore my setting, so I just made /var/backup a symbolic link to /mnt/home/backup. Works fine.

The next thing was to set up a cron job to dump my postgresql databases to a file, and then that file can be backed up along with everything else. The first thing I changed was when cron jobs are run. I edited /etc/crontab and changed the second column, which is the hour column, from 6 (as in 6 AM) to 0 (as in midnight). From what I read, you don’t have to do anything special for cron to pick up changes to /etc/crontab.

A little tangent here. I learned that there is good old cron, which runs a job only if the computer is on when that job is scheduled, and then there is anacron, which runs jobs whenever it can, apparently, to meet the broader scheduling criteria, such as daily, weekly, or monthly. It uses a separate program called run-parts to run scripts found in /etc/con.daily, /etc/cron.weekly, etc. run-parts puts timestamps in /var/spool/anacron/ to let anacron known when jobs were run last. It appears that on my Ubuntu Dapper Drake box, both cron and anacron run together? How? Well, /etc/crontab uses run-parts to run the same /etc/cron.* scripts that anacron does. Pretty tricky.

So, to add a postgresql-backup cron job, I just created a shell script in /etc/cron.daily called, postgresql-backup. I put the right shell commands in there, and I think that should do it.

One more thing I noticed poking around cron and /var. There is a cron script in cron.daily called standard. It backs up some important system files like /etc/password and /etc/shadow to /var/backups. That could come in handy some day for somebody, I’m sure.

Posted by Bryan on September 2, 2006

Comments

Post a comment


Topics

Highlights

Other Stuff

rss feed for latest comments Latest comments feed

What are these orange icons?

Search This Site

Archives


This site assembled by Bryan Murdock, using: