Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
A backup script using flexbackup and scp
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
beltazore
Apprentice
Apprentice


Joined: 30 Oct 2003
Posts: 174
Location: Norway

PostPosted: Sat Mar 19, 2005 2:28 pm    Post subject: A backup script using flexbackup and scp Reply with quote

I worte a little script for backing up directories of chooise
The scripts uploads the backed up files to a server via scp.

First you will have to emerge flexbackup
Code:
emerge flexbackup


Then you have to change a variabel in the /etc/flexbackup.conf
look for
Code:
#  $set{'set1'} = "/home /usr";

Uncomment it set the dirs you want to backup there.
I have:
Code:

$set{'set1'} = "/etc /boot /var/www";


Then you can download the script and change the variables on the top.
Code:
#!/bin/bash
#THE BACKUP WILL BE STORED IN $BACKUP_DIR/$DATE.
#The dirs to backup are defined in /etc/flexbackup.conf with the variable $set{'set1'}
#I will change this later.
#Variables used later.

BACKUP_DIR="/root/backup" #the backup dir on localhost
BACKUP_SERVER="serv1"     #the server where you want to move your backup
USER="root"               #the user you want to connect as.
DATE="$(date +%H:%M-%d.%m.%Y)" #This is the format for a dated dir.
DIR="/backup"               #the backup dir on your server
LOG_DIR="/var/log/flexbackup/" #the dir where you want to store your log files.
LOG_FILENAME="log"         #The filename of the log.

#Variables finished
clear
#Check if $LOG_DIR exists, if not the script will create it.
if [ -d $LOG_DIR ]
then
echo The log directory exists.
else
mkdir $LOG_DIR
fi

# Check if $BACKUP_DIR/today exists, if not the script will create it.
if [ -d $BACKUP_DIR/today ]
then
echo The today directory exists.
else
mkdir $BACKUP_DIR/today
fi

#Done createing dir's, now starting backup. 

echo
echo Checking syntax and starting backup
flexbackup -set all -device $BACKUP_DIR/today > $LOG_DIR/$LOG_FILENAME-$DATE && #Runing flexbackup.
cd $BACKUP_DIR
mkdir $DATE
mv $BACKUP_DIR/today/* $BACKUP_DIR/$DATE
#Finished backing up now were going to upload and delete the files on localhost.

scp -r $BACKUP_DIR/$DATE $USER@$BACKUP_SERVER:$DIR #This will upload the files to your server.
#DELETING FILES.This will delete the backup files on localhost. Comment out if you want to
rm -rf $BACKUP_DIR/$DATE
rm -rf $BACKUP_DIR/today


You can also use this script to backup to a harddrive with out using scp, just comment out the last 3 commands and the files will be stored on your localhost.
I hope some of you will find this usefull.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum