The House is on Fire!
- 0
- Add a Comment
- No Related Post
The House Is On Fire!
Crisis Management in Linux
There’s nothing in the computer world quite like backups. We all clearly understand the necessity of creating them regularly, but few of us actually do it. Linux is particularly well equipped for creating these backups and doing it, for the most part, completely in the background. These backups can be a crucial part of crisis management in Linux, as well. If all else fails, restore the backup.
Let’s start with a couple of commands that you’ll find useful for creating incremental backups - backups that pay attention to the files that have changed since the last backup. Using cron, these backups can be created daily, weekly or monthly. If you’re especially paranoid, you could even do them hourly or by the minute. My cron jobs include many incremental backups that are performed weekly, and a few that are performed monthly. We’ll talk about adding those commands to cron in the next few days. For now, take a look at a basic command for incremental backups:
find / -mtime -1 \! -type d -print > /home/tony/backups/new.list
This should, of course, be entered on a single command line. This command instructs the computer to [find] all files beginning from [/] that have changed in the past 24 hours [-mtime 1], excluding [\! -type] [d]irectories, then send the resulting output [-print >] to a file in the /home/tony/backups directory named new.list. In other words, this command executes a global search for files modified in the last day and lists those files in another file. Writing these changes to a file is especially useful, because many of the programs used to actually create backups can take their input from files.
Suppose, now, that you want to backup these files to floppy (Yes - it still can be done!). tar is the perfect command to use to create this floppy backup. First, mount the floppy drive:
mount /mnt/floppy
Then, write the backups to the disk:
tar -cv -T /home/tony/backups/new.list -f /mnt/floppy
This command, as I’ve mentioned, uses the new.list list we created in /home/tony/backups/ to tar the files changed in the past 24 hours and write them to the floppy disk.
Later, we’ll take a look at creating scripts that can be called from cron for executing these backup commands behind the scenes. For now, take this crisis management tip away from today’s Penguin Shell - backup, backup, backup. Even though we all hate to be in a position to restore them, they can end a crisis quickly in Linux.
