GnomeEasyBackup


Project Information

Overview

Gnome already has some features (such as Nautilus Script and Emblems) suitable to be used as part of backup application. Most backup application does not make use of those but instead create its own interface causing an additional learning curve to the application. GnomeEasyBackup aims to explore the possibilities of integrating and using those gnome's features for backup application.

Using Gnome's existing features for Backup Solution

GnomeEasyBackup uses rdiff-backup as back-end. rdiff-backup is a popular backup solution as it is very reliable. Like other backup solution, using rdiff-backup involves specifying files/folders to be included or excluded in the backup as well as the location of the backup repository. Most backup solution provide its own GUI for specifying the repository and those included/excluded as well as the interface for user to revert the changes of the files or recover the deleted files. Many of these can be done using gnome's features as described in the following:

  • Use Nautilus emblems to specified included and excluded.
  • Use Nautilus script to direct the action like "revert" or "recover" to a folder
  • Zenity can be used to further providing GUI such as selecting the version/time of files to revert or the file to recover.

Specifying the backup repository or the scheduling time-period are only needed to be done once or a few times so they can done with configuration file. Others operations such as adding bulk included/excluded or pre/post-backup are more advance so they also can be done with configuration file. A dedicated GUI can be created to modified the configuration file.

Progress

The current (initial) version of GnomeEasyBackup contains a fulling working prototype of the software. I, personally, use it in production environment for months with great reliability (Thanks to rdiff-backup :p).

  • All parts that are integrated with Nautilus and Zenity are done.
    • Use Nautilus emblems to specified included and excluded.
    • Use Nautilus script to direct the action like "revert" or "recover" to a folder
    • Zenity can be used to further providing GUI such as selecting the version/time of files to revert or the file to recover.
  • The backup repository is specified in the configuration file.
  • The scheduling time-period is specified using command line.
  • Advance included/excluded and pre/post-backup are specified in the configuration file.

Blueprint

Official Blueprint on launchpad is here.

Roughtly:

  • Installation should be made easier.
  • Dedicate configuration GUI should be made.
  • The problem should be ported to Python or Ruby (it is now PHP) to reduce dependent and to made GUI easier to made.

NOTE

Feel free to port the idea to other projects (It's opensource, right. :D).

Screenshorts

Scheduled Backup (this example is for very 10 minutes).

Scheduled Backup (this example is for very 10 minutes).

Add emblems to be used in Nautilus.

Add emblems to be used in Nautilus.

Applied emblems to specified included/excluded.

Applied emblems to specified included/excluded.

Revert a file to the older version.

Revert a file to the older version.

Recover the deleted file.

Recover the deleted file.

Files and Downloads

Souce Code on LaunchPAD is here

The lastest release on LaunchPAD is here

Installation and Uninstallation

Installation

Download the file installer.sh from LaunchPAD and execute it. The installer will ask you to select a backup repository location. The location is where the snapshots are.

The installer code is at follow:

#!/bin/sh

CURRENT=$(pwd)

EBTEMP=/tmp/EasyBackup

EBINST=/opt
EBPATH=$EBINST/EasyBackup
EBSOURCE=$EBPATH/source
EBCONFS=$EBPATH/confs
EBEMBLEMS=$EBPATH/resources/emblems

EASYBACKUP=~/.EasyBackup
NSCRIPT=~/.gnome2/nautilus-scripts/Easy\ Backup
EMBLEMS=~/.icons/hicolor/48x48/emblems/

EBDOWNLOAD=http://launchpad.net/gnomeeasybackup/release-0.1a/0.1a/+download/
EBDIST=EasyBackup-release-0.1a.tar.gz

EMBLEMSPREFIX="emblem-geb-"

echo "Install neccessary packages ---------------------------------------------------"
gksudo "apt-get install -y php5-cli rdiff-backup"

cd /tmp

echo "Download the file -------------------------------------------------------------"
wget $EBDOWNLOAD/$EBDIST

echo "Extract the file --------------------------------------------------------------"
tar -xzf /tmp/$EBDIST
rm -f /tmp/$EBDIST

echo "Copy the file to the installed folder -----------------------------------------"
gksudo "cp -R $EBTEMP $EBINST"

echo "Create the target folder ------------------------------------------------------"
mkdir -p $EASYBACKUP/logs

echo "Links the executables ---------------------------------------------------------"
ln -sf "$EBSOURCE/php/EasyBackup.php"  "$EASYBACKUP/EasyBackup.php"
ln -sf "$EBSOURCE/php/EasyRecover.php" "$EASYBACKUP/EasyRecover.php"
ln -sf "$EBSOURCE/php/EasyRevert.php"  "$EASYBACKUP/EasyRevert.php"

echo "Select the repository location ------------------------------------------------"
backuprepo=$(zenity --file-selection --directory --title="Select the backup repository location.")
backuprepo=$(echo $backuprepo | sed 's/\//\\\\\//g')
sed 's/^BackupDIR.*/BackupDIR = "'$backuprepo'\/"/g' "$EBCONFS/default.ini" > "$EASYBACKUP/default.ini"

echo "Create Nautilus Script --------------------------------------------------------"
mkdir -p "$NSCRIPT"
ln -sf "$EASYBACKUP/EasyBackup.php"  "$NSCRIPT/Backup"
ln -sf "$EASYBACKUP/EasyRecover.php" "$NSCRIPT/Recover"
ln -sf "$EASYBACKUP/EasyRevert.php"  "$NSCRIPT/Revert"

echo "Install emblems into Nautilus -------------------------------------------------"
mkdir -p $EMBLEMS
cp -f "$EBEMBLEMS/"$EMBLEMSPREFIX*.icon "$EMBLEMS"
cp -f "$EBEMBLEMS/"$EMBLEMSPREFIX*.png  "$EMBLEMS"

echo ""
echo "Finish :-D"
echo "Thank you for testing EasyBackup. Please give some feed back at http://launchpad.net/gnomeeasybackup"
echo "To uninstall type: sudo /opt/EasyBackup/uninstall.sh"

Msg="Thank you for testing EasyBackup.\n\n"
Msg=$Msg"See usages information see:\n\thttps://wiki.ubuntu.com/GnomeEasyBackup#Basic Usages\n\n"
Msg=$Msg"Please give some feed back at:\n\thttp://launchpad.net/gnomeeasybackup.\n\n"
Msg=$Msg"To uninstall type:\n\tsudo /opt/EasyBackup/uninstall.sh\n"
zenity --info --text="`printf "$Msg"`"

cd $CURRENT

You may choose to run it selectively.

Uninstall

If you install it with the installer script above, you can uninstall EasyBackup by simply running  /opt/EasyBackup/uninstall.sh . Otherwise use its code below:

which bash > /tmp/null
rm -f /tmp/null

EBINST=/opt
EBPATH=$EBINST/EasyBackup

EASYBACKUP=~/.EasyBackup
EMBLEMS=~/.icons/hicolor/48x48/emblems/

EMBLEMSPREFIX="emblem-geb-"

echo "Remove EasyBackup from /opt ---------------------------------------------------"
gksudo "rm -Rf $EBPATH"

BackupDIR=""
if [ -e "$EASYBACKUP/default.ini" ]; then
        BackupDIR=$(cat $EASYBACKUP/default.ini | grep -oe "BackupDIR = .*" | grep -oe "\".*\"$")
        if [ ${#BackupDIR} -gt 2 ]; then
                BackupDIR=${BackupDIR:1:${#BackupDIR}-2};
        fi
fi

if [ "`zenity --question --text="Do you want to remove the configuration files as well?" --ok-label="Keep" --cancel-label="Delete" && echo $?`" = "" ]; then
        echo "Remove EasyBackup from user home ----------------------------------------------"
        rm -Rf "$EASYBACKUP"
fi

if [ "`zenity --question --text="Do you want to remove the nautilus emblems as well?" --ok-label="Keep" --cancel-label="Delete" && echo $?`" = "" ]; then
        echo "Remove emblems from Nautilus --------------------------------------------------"
        rm -f "$EMBLEMS/"$EMBLEMSPREFIX*.icon
        rm -f "$EMBLEMS/"$EMBLEMSPREFIX*.png
fi

if [ ${#BackupDIR} -gt 0 ]; then
        if [ "`zenity --question --text="$(printf "Do you want to remove the backup file as well?")" --ok-label="Keep" --cancel-label="Delete" && echo $?`" = "" ]; then
                echo "Remove backup repository ------------------------------------------------------"
                rm -Rf "$BackupDIR"
        fi
fi

echo "Thank you for testing EasyBackup. Please give some feed back at http://launchpad.net/gnomeeasybackup"

Msg="Thank you for testing EasyBackup.\n\n"
Msg=$Msg"Please give some feed back at:\n\thttp://launchpad.net/gnomeeasybackup."
zenity --info --text="`printf "$Msg"`"

Basic Usages

After running the installation code above, you are almost ready. You need to log out and log in in order to let emblems installation takes effect. Then you can begin using emblems to mark what file to be included or excluded. By default, all files/folders are excluded.

  • At this point, you can use "To Backup" emblems to mark what to be included and use "To Not Backup" emblems to marks the files/folders to be excluded. If a folder is marked as included, all files and folders inside it will also be included unless they are marked as excluded (same goes the other ways around). If a symbolic-link is marked as included, the actual file it linked to are included.
  • Once included/excluded are marked (you can do it progressively), You can perform the backup by typing:

/opt/EasyBackup/EasyBackup.php
  • If you want GnomeEasyBackup to product a log file, use "-l" option.

  • You can set schedule backup by (e.g., for every 7 days):

/opt/EasyBackup/EasyBackup.php -I 7D
  • You can use a non-default configuration by using "--ConfigFile" option. For example:

/opt/EasyBackup/EasyBackup.php --ConfigFile weekly.ini -I 7D

Configurations

Basic setup

For a basic user data (as oppose to administrative) backup, there is only one configuration item that is needed to be set. Then if you want to schedule an automatic backup, you need to run one command and then you are ready to go :D.

Step 1: Set the backup directory

  • NOTE: If you run the installation script, the script should already ask you for that. You can skip to step 2.

  • Open the default configuration file "/home/<username>/.EasyBackup/default.ini"

  • Look for an item named "BackupDIR" (on the line # 9) and change the path to where you want the backup file will go.
  • Create a folder with the same name of the user immediately inside the "BackupDIR" and make it writable to the you

For example, if your username is "user" and "BackupDIR" is set to "/media/Extra/Backup/", create a folder name "user" inside it using

sudo mkdir -p "/media/Extra/Backup/user"

then set the permission

sudo chown user:user "/media/Extra/Backup/user"
sudo chmod 755 "/media/Extra/Backup/user"

Step 2: Setup automatic backup

  • Open terminal and run

.EasyBackup/EasyBackup.php -I 10min

This will set an automatic backup for every 10 minutes. You can set 1 day by using "-I 1day" or two weeks for "-I 2week". (accept min, hour, day, week, month).

  • Done. Big Grin :)

(More) Advance setup

There are number of options you can set in the configuration files. I provide here a brief description here and more detail may be added later.

  1. BackupDIR (path)
    • The path (with tail slashes) where you want the backup file to be. This path must be exclude from the backup either with emblems or exclude config item (see below).
  2. BackupAsRoot (boolean)

    • Whether or not the backup is run as root.
  3. OpenTerminal (boolean)

    • Whether or not a terminal windows will be opened when an automatic backup is invoked. (so that you can see its output)
  4. RemoveOlderThan (time period)

    • The age of snapshots that should be deleted. For example, \u201c2W\u201d means that every snapshots older than 2 weeks will be deleted.
  5. EmplemsToIncluded[] (array of emblem names)

    • An array of emblem names you use to flag included files/folders.
  6. EmplemsToExcluded[] (array of emblem names)

    • An array of emblem names you use to flag excluded files/folders.
  7. PreBackupCommand (shell command)

    • The shell command to be executed just before the backup is executed. If the command return a string starting with \u201cEVALME: \u201d the string will be executed (using php command eval). The building program, will remind you if the backup is not mounted.
  8. PostBackupCommand (shell command)

    • The shell command to be executed just before the backup is executed. If the command return a string starting with \u201cEVALME: \u201d the string will be executed (using php command eval). The building program, will remind you if the backup is not mounted.
  9. EnableCronJobEmail (boolean)

    • Whether or not the notification email will be send (by cron) when an automatic backup is run.
  10. !Parameters[] (array of rdiff-backup parameter)
    • The rdiff-backup parameter that is not includes or excludes (well you can put those here too if you want). These parameters will be added into the rdiff-backup command before includes and excludes so they are high-priority ones.
  11. !Includes[] (array of rdiff-backup include item)
    • Here is where you add the includes that cannot be specified by emblems such as *.avi or cache folder. It use shell pattern matching.
  12. !Excludes[] (array of rdiff-backup exclude item)
    • Here is where you add the includes that cannot be specified by emblems such as *.avi or cache folder. It use shell pattern matching.

NOTE: the emblem names that GnomeEasyBackup extract from gnome are not necessary the same as the one displayed in nautilus so not all emblem names can be use directly with EmplemsToIncluded[] and EmplemsToExcluded[] especially the built-in emblems. There is a way to check that but I have not had time to write a program to check that automatically. Therefore, for the moment, it is recommended that only the given emblems or the one created and added by you are to be used and the emblems name must be all alphabets (no number, no space and no symbol).

Bug Reports

Bug Reports and tracking on LaunchPAD is here.


CategoryHomepage

GnomeEasyBackup (last edited 2009-01-04 21:19:28 by nawaman)