Usage examples

From BackupManagerWiki
Jump to: navigation, search

This page is dedicated to real-life experiences about Backup Manager. Feel free to add your own here.

[edit] Home office backup (abadr)

I do a lot of work on my home workstation. I have BM backup my work daily to the media server, also at home, and then upload the archives to the office server via SSH. I don't need to encrypt the archives. Here's my configuration:

I mount my network backup share from the media server to the following location which I specify in BM:

export BM_REPOSITORY_ROOT="/mnt/backup/backup-manager"

I want to use incremental backup and also backup my MySQL database:

export BM_ARCHIVE_METHOD="tarball-incremental mysql"

I want to use the compressed tar format for my archives:

export BM_TARBALL_FILETYPE="tar.gz"

I want to backup my system configuration directory, my home directory and my home web server documents directory:

export BM_TARBALL_DIRECTORIES="/etc /home/abadr /var/www"

I don't need to backup the temp files that reside in my home directory like thumbnails and browser cache so I exclude them:

export BM_TARBALL_BLACKLIST="/home/abadr/.thumbnails /home/abadr/.opera/cache4 ...."

I want the master backup to be created weekly on friday (the 5th day of the week):

export BM_TARBALLINC_MASTERDATETYPE="weekly"
export BM_TARBALLINC_MASTERDATEVALUE="5"

I want BM to keep my backup archives for 15 days so that I always have 2 full backup sets:

export BM_ARCHIVE_TTL="15"

I want to backup my Mysql database as well:

export BM_MYSQL_ADMINLOGIN="mysql_root_user"
export BM_MYSQL_ADMINPASS="root_password"
export BM_MYSQL_HOST="localhost"

I want to upload the backup to the office server. The archives are not encrypted so I need to transfer them over a secure connection. And I want BM to purge old archives on the remote server like it does on the local one:

export BM_UPLOAD_SSH_USER="username"
export BM_UPLOAD_SSH_KEY="my_ssh_key"
export BM_UPLOAD_SSH_HOSTS="server.domain.com"
export BM_UPLOAD_SSH_DESTINATION="/mnt/backup/backup-manager/homews"
export BM_UPLOAD_SSH_PURGE="true"

That's all folks.

[edit] NAS backup (QNAP 209 II)

Before getting Backup-Manager running on this machine, there is a lot of work.

The first thing you have to do is to install Optware IPKG with the integrated QPKG software manager (via System Tools, QPKG).

For the installation to success, the NAS must have an access to the internet.

Next, you'll have to ssh into the NAS, and log in via the root username / password.

You must then add this line:

src cs05q3armel http://ipkg.nslu2-linux.org/feeds/optware/cs05q3armel/cross/stable

to this file:

/share/MD0_DATA/.qpkg/Optware/etc/ipkg.conf

(Please note that depending on your drivve configuration, MD0_DATA may be replaced by HDx_DATA, with x from A to Z)

You can do that with vi or more quickly with this command:

echo "src cs05q3armel http://ipkg.nslu2-linux.org/feeds/optware/cs05q3armel/cross/stable" >> /share/MD0_DATA/.qpkg/Optware/etc/ipkg.conf

Now do an update of IPKG:

ipkg update

You can now download the source of backup-manager.

Extract the archive somewhere, for example in /home/, with this command:

tar -xf backup-manager-0.7.8.tar.gz

You now have to modify the Makefile, because there is no root user in the system (only an admin, and the same for the group, no root group but an administrators group). The second difference lies also in the "install" command. As this command does not belong to the latest GNU-coreutils, it will not work correctly.

So you must change the argument of all the call to "install" from

--owner=root --group=root --mode=0xxx
to
-m=0xxx

If you want to you can leave the options for owner and group (under the form -o and -g) but I'm not sure this will work correctly.

You should then obtain something similar to this:

# Copyright © 2005-2006 The Backup Manager Authors
# See the AUTHORS file for details.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

# Makefile for Backup Manager written by Alexis Sukrieh,
# smart ideas for finding out perl libraries' destination come
# from Thomas Parmelan.

# $Revision: 588 $
# $Date: 2009-02-01 14:20:05 +0100 (dim 01 fév 2009) $
# $Author: sukria $


# Overwrite that variable if you need to prefix the destination
# (needed for vendors).
DESTDIR?=

# Overwrite that variable with the Perl vendorlib Config value if
# you package Backup Manager
PERL5DIR?="$(DESTDIR)$(shell perl -MConfig -e 'print "$$Config{sitelib}"')"

# Some static paths, specific to backup-manager
LIBDIR=$(DESTDIR)/usr/share/backup-manager
CONTRIB=$(LIBDIR)/contrib
SHAREDIR=$(DESTDIR)/usr/share/backup-manager
SHFILES=\
        lib/externals.sh \
        lib/dialog.sh \
        lib/files.sh \
        lib/actions.sh \
        lib/dbus.sh \
        lib/backup-methods.sh\
        lib/upload-methods.sh\
        lib/burning-methods.sh\
        lib/logger.sh \
        lib/gettext.sh \
        lib/gettext-real.sh \
        lib/gettext-dummy.sh \
        lib/sanitize.sh \
        lib/md5sum.sh

# For the backup-manager-doc package
DOCDIR           = $(DESTDIR)/usr/share/doc/backup-manager
DOCHTMLDIR       = $(DOCDIR)/user-guide.html
DOCPDF           = doc/user-guide.pdf
DOCHTMLFILES = doc/user-guide.html/*.html
DOCPDF           = doc/user-guide.pdf
DOCTXT           = doc/user-guide.txt

# Main build rule (we don't buid the docs as we don't know if debiandocs can be
# there) so the docs target has to be called manually by vendors.
build: manpages

# The backup-manager package
install: build install_lib install_bin install_contrib install_man install_po
install_binary: build install_lib install_bin

install_contrib:
        @echo -e "*** Contrib files ***\n"
        install -d $(CONTRIB)
        install -m0755 contrib/*.sh $(CONTRIB)

# The backup-manager-doc package
install_doc:
        @echo -e "\n*** Building the User Guide ***\n"
        $(MAKE) -C doc DESTDIR=$(DESTDIR)
        install -d $(DOCDIR)
        install -m=0644 $(DOCPDF) $(DOCDIR)
        install -m=0644 $(DOCTXT) $(DOCDIR)
        install -d $(DOCHTMLDIR)
        install -m=0644 $(DOCHTMLFILES) $(DOCHTMLDIR)

# The translation stuff
install_po:
        $(MAKE) -C po install

# The backup-manager libraries
install_lib:
        @echo -e "\n*** Installing libraries ***\n"
        install -d $(LIBDIR)
        install -m=0644 $(SHFILES) $(LIBDIR)

# The main stuff to build the backup-manager package
install_bin:
        @echo -e "\n*** Installing scripts ***\n"
        mkdir -p $(DESTDIR)/usr/sbin
        mkdir -p $(DESTDIR)/usr/bin
        mkdir -p $(SHAREDIR)
        install -m=0755 backup-manager $(DESTDIR)/usr/sbin
        install -m=0755 backup-manager-purge $(DESTDIR)/usr/bin
        install -m=0755 backup-manager-upload $(DESTDIR)/usr/bin
        install -m=0644 backup-manager.conf.tpl $(SHAREDIR)

        mkdir -p $(PERL5DIR)
        mkdir -p $(PERL5DIR)/BackupManager
        install -m=0644 BackupManager/*.pm $(PERL5DIR)/BackupManager

# Building manpages
man/backup-manager-upload.8:
        PERL5LIB=. pod2man --section 8 --center="backup-manager-upload" backup-manager-upload > man/backup-manager-upload.8

man/backup-manager-purge.8:
        PERL5LIB=. pod2man --section 8 --center="backup-manager-purge" backup-manager-purge > man/backup-manager-purge.8

# build the manpages
manpages: manpages-stamp
manpages-stamp: man/backup-manager-upload.8 man/backup-manager-purge.8
        touch manpages-stamp

# Installing the man pages.
install_man: manpages-stamp
        @echo -e "\n*** Installing man pages ***\n"
        install -d $(DESTDIR)/usr/share/man/man8/
        install -m=0644 man/*.8 $(DESTDIR)/usr/share/man/man8/

testperldir:
        @echo "PERL5DIR: $(PERL5DIR)"

docs:
        make -C doc all

clean:
        rm -f build-stamp
        rm -rf debian/backup-manager
        rm -f man/backup-manager-upload.8
        #rm -f man/*.8
        $(MAKE) -C po clean
        $(MAKE) -C doc clean

Then, you have to install make:

ipkg install make

And now you can run (in the directory you extracted backup-manager):

make install

Then, copy the template configuration to an actual readable file by backup-manager:

cp /usr/share/backup-manager/backup-manager.conf.tpl /share/MD0_DATA/.qpkg/Optware/etc/backup-manager.conf

Then edit the file with vi to enter your parameters.

The next step is to add the path to backup-manager (/usr/sbin) to /etc/profile, so you can actually launch it without spelling the whole address.

So edit /etc/profile with vi, and add in the last line the path /usr/sbin.

The last line should look like this (even if it's not exactly the same!):

export PATH=/bin:/sbin:/usr/bin:/opt/bin:/opt/sbin:/usr/sbin

Now, before actually launching backup-manager, you have to install gnu-coreutils and findutils.

ipkg install coreutils findutils

The end of the installation should link all the old functions to the new one, but this link doesn't seem to be created (maybe because the file already exist).

Anyway, to check that, you can just do for example "date --help". If the good version is installed and linked properly, you should get an ouput like this:

[/] # date --help
Usage: date [OPTION]... [+FORMAT]
  or:  date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]
Display the current time in the given FORMAT, or set the system date.

  -d, --date=STRING         display time described by STRING, not `now'
  -f, --file=DATEFILE       like --date once for each line of DATEFILE
  -r, --reference=FILE      display the last modification time of FILE
  -R, --rfc-2822            output date and time in RFC 2822 format.
                            Example: Mon, 07 Aug 2006 12:34:56 -0600
      --rfc-3339=TIMESPEC   output date and time in RFC 3339 format.
                            TIMESPEC=`date', `seconds', or `ns' for
                            date and time to the indicated precision.
                            Date and time components are separated by
                            a single space: 2006-08-07 12:34:56-06:00
  -s, --set=STRING          set time described by STRING
  -u, --utc, --universal    print or set Coordinated Universal Time
      --help     display this help and exit
      --version  output version information and exit

FORMAT controls the output.  Interpreted sequences are:

  %%   a literal %
  %a   locale's abbreviated weekday name (e.g., Sun)
  %A   locale's full weekday name (e.g., Sunday)
  %b   locale's abbreviated month name (e.g., Jan)
  %B   locale's full month name (e.g., January)
  %c   locale's date and time (e.g., Thu Mar  3 23:05:25 2005)
  %C   century; like %Y, except omit last two digits (e.g., 20)
  %d   day of month (e.g, 01)
  %D   date; same as %m/%d/%y
  %e   day of month, space padded; same as %_d
  %F   full date; same as %Y-%m-%d
  %g   last two digits of year of ISO week number (see %G)
  %G   year of ISO week number (see %V); normally useful only with %V
  %h   same as %b
  %H   hour (00..23)
  %I   hour (01..12)
  %j   day of year (001..366)
  %k   hour ( 0..23)
  %l   hour ( 1..12)
  %m   month (01..12)
  %M   minute (00..59)
  %n   a newline
  %N   nanoseconds (000000000..999999999)
  %p   locale's equivalent of either AM or PM; blank if not known
  %P   like %p, but lower case
  %r   locale's 12-hour clock time (e.g., 11:11:04 PM)
  %R   24-hour hour and minute; same as %H:%M
  %s   seconds since 1970-01-01 00:00:00 UTC
  %S   second (00..60)
  %t   a tab
  %T   time; same as %H:%M:%S
  %u   day of week (1..7); 1 is Monday
  %U   week number of year, with Sunday as first day of week (00..53)
  %V   ISO week number, with Monday as first day of week (01..53)
  %w   day of week (0..6); 0 is Sunday
  %W   week number of year, with Monday as first day of week (00..53)
  %x   locale's date representation (e.g., 12/31/99)
  %X   locale's time representation (e.g., 23:13:48)
  %y   last two digits of year (00..99)
  %Y   year
  %z   +hhmm numeric timezone (e.g., -0400)
  %:z  +hh:mm numeric timezone (e.g., -04:00)
  %::z  +hh:mm:ss numeric time zone (e.g., -04:00:00)
  %:::z  numeric time zone with : to necessary precision (e.g., -04, +05:30)
  %Z   alphabetic time zone abbreviation (e.g., EDT)

By default, date pads numeric fields with zeroes.
The following optional flags may follow `%':

  -  (hyphen) do not pad the field
  _  (underscore) pad with spaces
  0  (zero) pad with zeros
  ^  use upper case if possible
  #  use opposite case if possible

After any flags comes an optional field width, as a decimal number;
then an optional modifier, which is either
E to use the locale's alternate representations if available, or
O to use the locale's alternate numeric symbols if available.

Report date bugs to bug-coreutils@gnu.org
GNU coreutils home page: <http://www.gnu.org/software/coreutils/>
General help using GNU software: <http://www.gnu.org/gethelp/>

If you obtain this output, just run backup-manager and everything should be running smoothly.

I used to change all the source code refering to "date", "find" and "du", but deleting the old symbolic link and creating a new one to the good file is a better option.

So you must do something like this:

mv /bin/date /bin/dateold
ln -s /opt/bin/coreutils-date /bin/date
mv /usr/bin/find /usr/bin/findold
ln -s /opt/bin/findutils-find /usr/bin/find
mv /usr/bin/du /usr/bin/duold
ln -s /opt/bin/coreutils-du /usr/bin/du

Now, if backup-manager is still not working, the last thing to do is to change the source code to call coreutils-date instead of date, findutils-find instead of find and coreutils-du instead of du. I will not give the howto for this, because if you want to change that, you must know what you are doing, and be very careful.


If you need more informations, or want to make any comment on this, just ask on the mailing-list.

Personal tools