0

How do I instruct Ubuntu 13.10 server to:

  1. zip svn repository
  2. dump mysql database into .sql script
  3. tar both files
  4. copy backup tar onto sdb disk

Are there any premade tools for such kind of operations?

2 Answers 2

4

The short answer is yes, there are premade tools for each of those operations:

  1. Use zip
  2. Use mysqldump
  3. Use tar
  4. Use cp

zip is not so often used in my experience. You get better compression, and preservation of more of the Linux specific file metadata by making a .tar file and compressing that (e.g. with xz).

You should just have to make a script that does all four tasks one after another and once that works, call that script on a daily basis using cron.

4

The Simple Approach

The normal Unix approach to things is to give you tools that do isolated tasks and ways to connect them together yourself. So, for example,

  • cron to schedule tasks to run regularly
  • numerous programs to make archives, zip makes zip files. Note that you may want to also use svnadmin hotcopy; check the Subversion docs for backup procedures.
  • mysqldump makes sql dumps of MySQL databases. There are some other options, too, such as Percona Xtrabackup. You should review the docs for these tools as well as MySQL; database backup is (or at least can be) non-trivial.
  • Tar files are, of course, made with tar. Though its not clear to me why you want to tar them.
  • cp is used to copy files. There are several more tools used in other situations (e.g., scp and rsync).

There are a few tools that are commonly used as the glue to hold this together. The most common one is shell scripting. A shell script looks something like this:

#!/bin/sh

zip -r destfile.zip a b c d
mysqldump --single-transaction > foo.sql

Note how it's just commands like you'd type them into the shell. Of course, it can be more complicated too—you can include variables, loops, conditionals, etc. (You can use those at the shell input prompt too.)

The Complex Approach

That approach isn't always right. When your backup scripts start to get complicated enough you have to wonder are they really working?, then you move on to a backup system. These handle things like scheduling backups, retrying them if they fail, producing reports, backups across multiple machines, ....

A couple that I have used are:

  • Backup PC — Good for smaller installations with disk-only backups. This is probably where you should start.
  • Bacula — I currently use this. It handles both to-disk and to-tape backups fairly well. VERY much harder to configure than BackupPC though.
  • AMANDA — I haven't used this for a while, I switched to Bacula instead. When I last used it, it was primarily for backups to tape.

Each of them has its own documentation; I will not attempt to repeat it here (at least for Bacula, its hundreds of pages).

A final note

Backups must be tested, and tested regularly. You shouldn't consider something backed up until you've tested restoring it. For example, when you restore, you may find that you didn't notice an error during the backup, and actually don't have a backup of a critical table. If you find that when testing, that's fine—you can fix it. If you only find out after a disaster strikes...

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .