13.07.2015 Views

Linux System Administration Recipes A Problem-Solution Approach

Linux System Administration Recipes A Problem-Solution Approach

Linux System Administration Recipes A Problem-Solution Approach

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER 4 ■ TAKING BACKUPS AND MANAGING DATA21 }22 }24 }2526 print "Total is: $total\nUsed is: $used\n";You’ll need to edit line 11 to have the names of all the machines you want to check. The main section of the script(lines 13–24) works exactly as described earlier.Lines 30–45 ssh into each machine in turn, get the disk information from df, and then parse it andadd the values to the running totals.You may be able to reduce this total if you usually have a separate root partition that contains only astandard install, and if you need to restore, you can do another standard reinstall rather than restoringfrom backup. However, since as discussed earlier you need to allow room for expansion, it’s probablybetter to overestimate than to underestimate your requirements.■ Note If you do decide not to back up /, be aware that you may want to back up /root, especially if you have atendency to keep useful scripts or other information there. You should also check where database and webinformation is kept (this is often in /var) and ensure that this is being backed up. If you’re not using centralizedconfig management (see Chapter 3), /etc may be another candidate for backup.4-2. Finding Out How Often Your Files ChangeAgain, to create your backup policy, it’s useful to know how often your files change. Here’s a script youcan run daily on each machine to find out:01 #!/bin/bash02 # Script to find and mail total size of files altered in the last 24 hrs03 # JK 25.03.20090405 TOTAL=006 HOST=`hostname`07 EMAIL="juliet@example.com"08 for FILE in `find / -mount -mtime -1`; do09 SIZE=`stat -c %s $FILE`10 TOTAL=$(($TOTAL+$SIZE))11 done99Download at WoweBook.Com

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!