Showing posts with label Backup. Show all posts
Showing posts with label Backup. Show all posts

Wednesday, November 21, 2007

Mysqldump certain tables

To take the Mysql dump of certain tables use the following command

mysqldump --user=username --password= password -B Database --tables Table1 Table2 Table3 Table4 > backup.sql

Wednesday, September 26, 2007

Disk Based Backups With Amanda On Debian Etch

This document describes how to set up Amanda (The Advanced Maryland Automatic Network Disk Archiver) on Debian Etch. For this tutorial I chose Ubuntu v7.04 as a backup-client. The resulting system provides a flexible backup-system with many features. It will be able to back up multiple hosts via network to various devices. I chose the disk based backup for this howto.
Read More...........

Monday, August 13, 2007

Backup hard disk partition table

dd the old good command which now backup partition tables even writes CDs ;). Backing up partition is nothing but actually backing up MBR (master boot record). The command is as follows for backing up MBR stored on /dev/sdX or /dev/hdX :

# dd if=/dev/sdX of=/tmp/sda-mbr.bin bs=512 count=1

Replace X with actual device name such as /dev/sda.

Now to restore partition table to disk, all you need to do is use dd command:

# dd if= sda-mbr.bin of=/dev/sdX bs=1 count=64 skip=446 seek=446

dd command works with Solaris, HP-UX and all other UNIX like operating systems. Read man page of dd for more info.

Wednesday, July 25, 2007

Mysql Backup Script

A script to take daily, weekly and monthly backups of your MySQL databases using mysqldump. Features - Backup mutiple databases - Single backup file or to a seperate file for each DB - Compress backup files - servers - remote servers - E-mail logs – More

AutoMySQLBackup Script Features

• Backup mutiple MySQL databases with one script. (Now able to backup ALL databases on a server easily. no longer need to specify each database seperately)
• Backup all databases to a single backup file or to a seperate directory and file for each database.
• Automatically compress the backup files to save disk space using either gzip or bzip2 compression.
• Can backup remote MySQL servers to a central server.
• Runs automatically using cron or can be run manually.
• Can e-mail the backup log to any specified e-mail address instead of "root". (Great for hosted websites and databases).
• Can email the compressed backup files to the specified email address.
• Can specify maximun size backup to email.
• Can be set to run PRE and POST backup commands.
• Choose which day of the week to run weekly backups.

AutoMySQLBackup Download

The AutoMySQLBackup project has now been moved to Sourceforge.net for better maintainence.

http://sourceforge.net/projects/automysqlbackup/

AutoMySQLBackup Requirements

The AutoMySQLBackup script only requires mysqldump (A standard utility provided with the mysql client) and gzip or bzip2 for compression of the backup files.

If you would like to have the log emailed to you then you will need to have permission to execute the "mail" program. If you want the compressed backup files mailed to you then Mutt must be available on the server.
Finally you will need a bash shell and the standard system tools and utilities (all these requirements should be the default on most linux system.)

What AutoMySQLBackup does

Every day AutoMySQLBackup will run (if setup on /etc/cron.daily) and using mysqldump and gzip will dump your specified databases to the /backups/daily directory, it will rotate daily backups weekly so you should never have more than 7 backups in there..

Every Saturday AutoMySQLBackup will again backup the databases you have chosen but they will be placed into /backups/weekly, these will be rotated every 5 weeks so there should never be more than 5 backups in there..

Every 1st of the month AutoMySQLBackup will create a backup of all databases and place them into /backups/monthly. These will never be rotated so it will be up to you to do your own house keeping. I would suggest taking a copy of this offline every month or two so that if you have a hard drive failure you will be able to restore your database..

AutoMySQLBackup Installation

The install is as simple as editing a few variables in the AutoMySQLBackup file. The full setup is documented in the AutoMySQLBackup script file below the variables section..

Here is a quick minimum setup step by step..

1. Download automysqlbackup.sh and place it into your /etc/cron.daily directory or your home directory.

2. Edit (at least) the following lines :-
USERNAME=dbuser (The user must have at least select privileges to the databases) PASSWORD=password
DBNAMES="DB1 DB2 DB3" (make sure to keep the quotes " " otherwise it won't work)

3. Make the file executable :- chmod u+rwx

4. Create the following directory./backups

5. That's it.. Now you can run it using the command line "./automysqlbackup.sh" or if it is in /etc/cron.daily it will run each day when cron runs.

Friday, July 20, 2007

Basic backup script using tar

If you are looking for a simple backup script using tar then the below script is enough.

*************************************************************************************
#!/bin/sh
# full and incremental backup script
# created 07 February 2000
# Based on a script by Daniel O'Callaghan
# and modified by Gerhard Mourani

#Change the 5 variables below to fit your computer/backup

COMPUTER=deep # name of this computer
DIRECTORIES="/home" # directoris to backup
BACKUPDIR=/backups # where to store the backups
TIMEDIR=/backups/last-full # where to store time of full backup
TAR=/bin/tar # name and locaction of tar

#You should not have to change anything below here

PATH=/usr/local/bin:/usr/bin:/bin
DOW=`date +%a` # Day of the week e.g. Mon
DOM=`date +%d` # Date of the Month e.g. 27
DM=`date +%d%b` # Date and Month e.g. 27Sep

# On the 1st of the month a permanet full backup is made
# Every Sunday a full backup is made - overwriting last Sundays backup
# The rest of the time an incremental backup is made. Each incremental
# backup overwrites last weeks incremental backup of the same name.
#
# if NEWER = "", then tar backs up all files in the directories
# otherwise it backs up files newer than the NEWER date. NEWER
# gets it date from the file written every Sunday.


# Monthly full backup
if [ $DOM = "01" ]; then
NEWER=""
$TAR $NEWER -cf $BACKUPDIR/$COMPUTER-$DM.tar $DIRECTORIES
fi

# Weekly full backup
if [ $DOW = "Sun" ]; then
NEWER=""
NOW=`date +%d-%b`

# Update full backup date
echo $NOW > $TIMEDIR/$COMPUTER-full-date
$TAR $NEWER -cf $BACKUPDIR/$COMPUTER-$DOW.tar $DIRECTORIES

# Make incremental backup - overwrite last weeks
else

# Get date of last full backup
NEWER="--newer `cat $TIMEDIR/$COMPUTER-full-date`"
$TAR $NEWER -cf $BACKUPDIR/$COMPUTER-$DOW.tar $DIRECTORIES
fi
*************************************************************************************