command line control on full - incremental backup

Asked by paolocollector

I need to specify in a script to do a full backup or an incremental backup
This does not seem to be possible at the moment: is this a planned feature?
It would be useful if you need to perform specific operations before backup that are different in the two cases

thanks
Paolo

Question information

Language:
English Edit question
Status:
Solved
For:
nssbackup Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Jean-Peer Lorenz (peer.loz) said :
#1

Hi Paolo,

you're right - at the moment a proper commandline interface providing some features/configuration tricks is not implemented. I've already thought about this and something in this direction is included in the current development branch (trunk - not for production!). I've registered a blueprint https://blueprints.launchpad.net/nssbackup/+spec/commandline-interface to track the progress on this feature. You are invited to contribute with ideas and specifications to this blueprint (What is it exactly what you need? What happens in the case of not being able to do an incr. backup? And so on.)

HTH,
Jean-Peer

Revision history for this message
paolocollector (paolocollector) said :
#2

Not sure how to contribute to the blueprint.
I can tell you why I need this.
I can't backup directly mysql and subversion databases, so i run a script to backup them to a specific folder, that becomes then part of nssbackup.
It would make sense to have a common policy where a full nssbackup is performed when i do a full mysql and svn backup, so i need to control it via script

Revision history for this message
Jean-Peer Lorenz (peer.loz) said :
#3

Just for curiosity: what commands are you using in order to backup these databases? Can you control whether a full or incremental backup is done?

Revision history for this message
paolocollector (paolocollector) said :
#4

here is the script:
basically it uses mysqldump or mysqladmin to backup mysql (full or incremental)
and two scripts to backup svn (will post them too if interested)
The script runs every day (if system is running) and performs a full backup after "maxIncDays" days

#!/bin/bash
#
# backup script used by anacron

maxIncDays=7
lastFullDateFile="/var/backup.extra/lastFullDateFile"
today=`date +%Y%m%d`
fullBackup=true

function dayDiff (){
 dateOfPast=$1
 timeStampToday=`date +%s -d $today`
 timeStampOfPast=`date +%s -d $dateOfPast`
 secondsInDay=86400
 dayDiff=`echo \($timeStampToday - $timeStampOfPast\) / $secondsInDay | bc`
 echo $dayDiff
}

#redirect stdout and stderr
logFile=/var/backup.extra/log/backup.`date +%Y-%m-%d`.log
errFile=/var/backup.extra/log/backup.`date +%Y-%m-%d`.err
exec &> $logFile
#exec 2> $errFile

echo "starting backup"|/usr/bin/wall

# if lastFullDateFile does not exist, set it to long time ago (backup will be done)
if [ ! -f $lastFullDateFile ]
then
 echo "20000101">$lastFullDateFile
fi

# get the last backup date and comare it to today
lastBackupDay=`cat $lastFullDateFile`
result=$(dayDiff $lastBackupDay )

# check result for a full or incremental backup
if [ "$result" -ge "$maxIncDays" ]
then
    full=true
 echo "$today">$lastFullDateFile
else
    full=false
fi

# extract mySql tables
if [ "$full" == true ]
then
 echo "full mySql backup begin..."
 mysqldump -proot --single-transaction --flush-logs --master-data=2 --all-databases --delete-master-logs > /var/backup.extra/mysql/fullBackup.sql
 echo "full mySql backup end"
else
 echo "incremental mySql backup begin..."
 mysqladmin -proot flush-logs
 echo "incremental mySql backup end"
fi

# extract subversion repository
if [ "$full" == true ]
then
 echo "full subversion backup begin..."
 /opt/scripts/svnFullBackup.pl
 echo "full subversion backup end"
else
 echo "incremental subversion backup begin..."
 /opt/scripts/svnIncBackup.pl
 echo "incremental subversion backup end"
fi

if [ -x /usr/bin/nssbackupd ]
then

 if [ "$full" == true ]
 then
  echo "full nssbackup backup begin..."
  /usr/bin/nssbackupd
  echo "full nssbackup backup end"
 else
  echo "incremental nssbackup backup begin..."
  /usr/bin/nssbackupd
  echo "incremental nssbackup backup end"
 fi

else
 echo error: /usr/sbin/sbackupd file not found
fi

echo "backup completed"|/usr/bin/wall

Revision history for this message
Jean-Peer Lorenz (peer.loz) said :
#5

In nssbackup 0.3 and in sbackup 0.11 (which you should prefer) you can now start the backup process with:

in nssbackup: >sbackupd --full
in sbackup: >sbackup --full

Revision history for this message
Jean-Peer Lorenz (peer.loz) said :
#6

Changing status to solved because it is obviously not longer an issue.