Database Reference
In-Depth Information
Exercises
A few exercises follow to get you more familiar with making backups with mysqldump , as
well as restoring them. You should try to complete all of the exercises. However, there are a
couple that might be too advanced. If you're having difficulty working through them, try
again later when you are more experienced.
1. So that you won't cause yourself problems with the other exercises here, make a
couple of backups for the first exercise. Using the mysqldump utility, make a
backup of all of the databases. Then make a backup of both the rookery and the
birdwatchers databases in one dump file. Don't use these two dump files for
the remaining exercises. Keep them in case something goes wrong and you need to
restore something.
2. Refer to the backup schedule in Table14-2 . It contains a list of backups to be made
regularly. There are two full backups and three backups based on tables. Make all
five backups in this schedule using mysqldump and name the dump files in accord-
ance with the naming pattern shown in the table for each.
3. Write five simple shell scripts, each to make a backup using mysqldump for each of
the backups listed in Table14-2 . Make it so that the names of the dump files that it
creates conform automatically to the naming pattern based on the current date, as
shown in Table14-2 . There is a script that can do this in Creating Backup Scripts .
You can copy this script and modify it, or you can write your own using a scripting
or programming language with which you're comfortable.
After you write the five scripts, execute them and see whether they create and
name the dump files correctly. If it won't cause problems to your server, add lines
to crontab or another scheduling utility to have the five scripts execute automatic-
ally, but at a time not long afterwards. Wait and see if they execute as scheduled.
You can remove the entries from crontab after you've tried this.
4. Modify the scripts that you created in the previous exercise and have the scripts re-
move older dump files, ones that are older than the amount of time set in the reten-
tion column for each table in Table14-3 . Make copies of the first set of dump files
you created with these scripts, but change the names so that the date part of the fi-
lenames are further back than the retention period. Make copies for dates that are
one and two days within the retention period and dates that are one and two days
outside of the retention period.
Run your scripts again to see whether they delete the dump files with the older
names. You may have to try this a few times to get it right, so that the scripts delete
the right dump files.
Search WWH ::




Custom Search