View previous topic :: View next topic |
Author |
Message |
_Razorblade_ n00b
Joined: 01 Jan 2004 Posts: 30
|
Posted: Thu Jan 01, 2004 3:13 pm Post subject: Intelligent backup? |
|
|
I browsed thorugh backup/restore related postings but didnt find anything helpful yet...
My situation is that I have a two remote servers with Gentoo without physical access and limited (expensive) bandwidth.
Due to the lack of physical access CD-R(W) or tapes are no option, full or even incremental backups could be to expensive.
The server to backup is a mail/web/sql server with potentially ~2GB of important data.
Another fact: If the server dies I cannot rely on getting the same hardware again, so my compiled binaries would be useless.
My idea would be a combination of:
- Backup up userdata (IMAP-folders, home-dirs, MySQL dumps+ ???) and settings (/etc + ???) full each (month/week) with daily incrementals
- save system specific data (list emerged ebuilds + current kernel config + ???) to be able to actually *rebuild* the complete system on a different machine
- have some binary data (running kernel + modules + ???) backed up anyway just in case I'm lucky and get compatible hardware (to save time)
I'm sure I missed a lot, so it would be great to get some help where I put question marks as well as some ideas for backup programs I could use (using scp for transfer to the other server).
Thanks and best regards! |
|
Back to top |
|
|
BackSeat Apprentice
Joined: 12 Apr 2002 Posts: 242 Location: Reading, UK
|
Posted: Thu Jan 01, 2004 8:30 pm Post subject: |
|
|
For backups, take a look at rdiff-backup.
BS |
|
Back to top |
|
|
ilikejonessoda n00b
Joined: 23 Jul 2002 Posts: 15
|
Posted: Tue Jan 06, 2004 6:52 am Post subject: |
|
|
rdiff-backup is sweet.. I use it to backup all of my internal/external servers. I hacked a quick little bash script that will generate a folder named based on the current week, so at the beginning of every week it does a full backup then from that day until the next week will be an incremental backup |
|
Back to top |
|
|
mal0 n00b
Joined: 24 Nov 2003 Posts: 19
|
Posted: Fri Jan 09, 2004 12:43 pm Post subject: |
|
|
would be nice if you could post your script |
|
Back to top |
|
|
ilikejonessoda n00b
Joined: 23 Jul 2002 Posts: 15
|
Posted: Wed Jan 28, 2004 8:37 am Post subject: |
|
|
I use it from cron as such
Code: |
/usr/local/bin/backup /srv/smb/development/cvsroot /srv/backup/development/ /cvsroot
|
/usr/local/bin/backup
Code: |
#!/bin/sh
function showUsage ()
{
echo "Usage: $0 source destination_prefix destination_suffix"
exit 1
}
# Setup Group Owner
GROUP_OWNER="Backup Operators"
# Test for valid parameters
if [ -z "$1" ]
then
showUsage
elif [ -z "$2" ]
then
showUsage
elif [ -z "$3" ]
then
showUsage
fi
FOLDER=`/usr/local/bin/backup_folder_name`
DEST_DIR="$2$FOLDER$3"
# Check to ensure the destination directory exists
if [ ! -d "$DEST_DIR" ]
then
mkdir -p $DEST_DIR
chown -R ."$GROUP_OWNER" "$2$FOLDER"
fi
echo -e "[$1]"
rdiff-backup --print-statistics $1 $DEST_DIR
if [ $? -eq 0 ]
then
chown -R ."$GROUP_OWNER" $DEST_DIR
chmod 750 $DEST_DIR
fi
|
/usr/local/bin/backup_folder_name
Code: |
#!/bin/sh
# This file is used for naming backup directories
# Uses `date` heavily
# Format for Week Start
WEEK_START="%Y%m%d.%A"
# Format for Week End
WEEK_END="$WEEK_START"
# Directory Separator
DIR_SEPARATOR="-"
# Get Today's Date
TODAY=`date +%D`
# Define Begin Date Variable
BEGIN_DATE="$TODAY"
# Define End Date Variable
END_DATE=""
function getBeginningOfWeek ()
{
if [ -z "$1" ]
then
echo "Error: Invalid date $1 - getBeginningOfWeek ()"
exit 1
fi
MNTH=`date -d "$1" +%m`
DOW=`date -d "$1" +%w`
YEAR=`date -d "$1" +%Y`
# Substract the Day of the Week from the Day of Month
DOM=$((`date -d "$1" +%e` - $DOW))
# Check to see if we need to go back a month
if [ $DOM -lt 0 ]
then
# Add the Negative Number to the last day of last month
DOM=$((`date -d "$MNTH/0/$YEAR" +%e` + $DOM))
# Subtract one from the month
MNTH=$(($MNTH - 1))
fi
# Check to see if we ned to go back a year
if [ $MNTH -lt 1 ]
then
# Set Month to 12 (December)
MNTH="12"
YEAR=$(($YEAR - 1))
fi
# Set Begin Date
BEGIN_DATE=`date -d "$MNTH/$DOM/$YEAR" +%D`
# Return success
return 0
} # getBeginningOfWeek
function getEndingOfWeek ()
{
# Check to see if we were passed something
if [ -z "$1" ]
then
echo "Error: Invalid date $1 - getEndingOfWeek ()"
return 1
fi
MNTH=`date -d "$1" +%m`
DOW=`date -d "$1" +%w`
YEAR=`date -d "$1" +%Y`
# Get Day of Week Offset
DOWO=$((6 - $DOW))
# Get Day of Week for Saturday
DOM=$((`date -d "$1" +%e` + $DOWO))
# Set End Date
END_DATE=`date -d "$MNTH/$DOM/$YEAR" +%D`
# Return Success
return 0
} # getEndingOfWeek
getBeginningOfWeek $TODAY
getEndingOfWeek $TODAY
# Construct Folder Name
FOLDER_NAME="`date -d "$BEGIN_DATE" +$WEEK_START`$DIR_SEPARATOR`date -d "$END_DATE" +$WEEK_END`"
echo "$FOLDER_NAME"
|
Sorry it took so long. |
|
Back to top |
|
|
|