Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
A daily cron script that backs things up into /backup/YYYY-MM-DD/
Shell Python Makefile
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
debian
.gitignore
Makefile
README.rst
cron_daily.sh
estimate.sh
example.conf
extract-documentation.py
functions.sh
pov-simple-backup.rst
pov-simple-backup.sh
tests.sh

README.rst

pov-simple-backup

A daily cron script that backs things up into /backup/YYYY-MM-DD/.

Quick start:

sudo add-apt-repository ppa:pov/ppa
sudo apt-get update
sudo apt-get install pov-simple-backup

Things you want to back up are configured in /etc/pov/backup, which is actually a shell file that is sourced from the cron script. If this file is missing, pov-simple-backup does nothing.

Example configuration file:

back_up /etc
back_up /root
back_up /usr/local
back_up /var/cache/debconf/config.dat
back_up_dpkg_selections
back_up_postgresql
clean_up_old_backups 14
copy_backup_to user@otherserver:/backup/myhostname/ -i /path/to/ssh-key.rsa

You can also run a backup manually by running pov-simple-backup. The following command-line options are available:

-h show a brief help message
-v print things that are being backed up
-n only print things that are being backed up, don't actually back them up
-o overwrite existing backup files
-s skip existing backup files
-S instead of taking a backup, estimate the size of backups
-f CONFIG-FILE use CONFIG-FILE instead of /etc/pov/backup

Backup commands for the config file

back_up <pathname> [<tar options>]

Back up a directory or a single file

Creates <filename>.tar.gz, where the <filename> is constructed from the <pathname> by stripping leading slashes and replacing all other slashes with hyphens.

Examples:

   back_up /var/cache/debconf/config.dat
   back_up /opt/myapp --exclude opt/myapp/var/zdaemonsock

would create var-cache-debconf-config.dat.tar.gz and opt-myapp.tar.gz

Note: when using tar's ``--exclude``, be sure to omit both the leading and
the trailing slash!  Otherwise it will be ignored.
back_up_to <name> <pathname> [<tar options>]

Back up a directory or a file.

Creates <name>.tar.gz.

Examples:

   back_up_to backup-skeleton /backups/host1 backups/host2 --no-recursive

Note: when using tar's ``--exclude``, be sure to omit both the leading and
the trailing slash!  Otherwise it will be ignored.

Note: you can back up multiple files/directories, but you'll have
to omit leading slashes to avoid warnings from tar.
back_up_uncompressed <pathname> [<tar options>]

Back up a directory or a single file

Creates <filename>.tar, where the <filename> is constructed from the <pathname> by stripping leading slashes and replacing all other slashes with hyphens.

Examples:

   back_up_uncompressed /git/myrepo.git

would create git-myrepo.git.tar

Note: when using tar's ``--exclude``, be sure to omit both the leading and
the trailing slash!  Otherwise it will be ignored.
back_up_uncompressed_to <name> <pathname> [<tar options>]

Back up a directory or a file.

Creates <name>.tar.

Examples:

   back_up_uncompressed_to backup-skeleton /backups/host1 backups/host2 --no-recursive

Note: when using tar's ``--exclude``, be sure to omit both the leading and
the trailing slash!  Otherwise it will be ignored.

Note: you can back up multiple files/directories, but you'll have
to omit leading slashes to avoid warnings from tar.
back_up_dpkg_selections

Back up dpkg selections (i.e. list of installed packages)

Creates dpkg--get-selections.gz and var-lib-apt-extended_states.gz

back_up_postgresql

Back up all PostgreSQL databases in the main cluster

Creates postgresql-dump.sql.gz

Bugs:

  • a single dump file for all databases is unwieldy
  • a text dump file is inefficient
back_up_mysql

Back up all MySQL databases

Creates mysql-dump.sql.gz

Bugs:

  • a single dump file for all databases is unwieldy
  • a text dump file is inefficient
back_up_svn <pathname>

Back up a single SVN repository

Creates <filename>.svndump.gz, where the <filename> is constructed from the <pathname> by stripping leading slashes and replacing all other slashes with hyphens.

Bugs:

  • does not back up hooks/ and conf/ subdirectories

Example:

back_up_svn /var/lib/svn/myrepo
back_up /var/lib/svn/myrepo/conf
back_up /var/lib/svn/myrepo/hooks
clean_up_old_backups <number> [<directory> [<suffix>]]

Remove old backups, keep last <number>

Example:

clean_up_old_backups 14
clean_up_old_backups 14 /backup/otherhost/
clean_up_old_backups 14 /backup/ -git

to keep just two weeks' backups

copy_backup_to [<user>@]<server>:<path> [<ssh options>]

Copy today's backups to a remote server over SSH

Alias for rsync_backup_to.

Example:

copy_backup_to backups@example.com:/backup/myhostname/ -i key.rsa

See also: rsync_backup_to, scp_backup_to

rsync_to <pathname> [<user>@]<server>:<path> [<ssh options>]

Mirror a file or directory to a remote server over SSH, using rsync

It means a lot to rsync whether or not you have a trailing slash at the end of <pathname>, when it's a directory. No trailing slash: it will create a new directory with the same basename on the server side, under <path>. Trailing slash: it will make the contents of <path> on the server the same as contents of <pathname> here.

Example:

rsync_to /var/www/uploads backups@example.com:/backup/myhostname/uploads -i key.rsa
rsync_backup_to [<user>@]<server>:<path> [<ssh options>]

Copy today's backups to a remote server over SSH, using rsync

Example:

rsync_backup_to backups@example.com:/backup/myhostname/ -i key.rsa

See also: scp_backup_to, copy_backup_to

scp_backup_to [<user>@]<server>:<path> [<scp options>]

Copy today's backups to a remote server over SSH, using scp

Destination directory must exist on the remote host.

Example:

copy_backup_to backups@example.com:/backup/myhostname/ -i key.rsa

Bugs:

  • if the remote directory already exists, creates a second copy, as a subdirectory (e.g. /backup/myhostname/2013-08-29/2013-08-29)

See also: rsync_backup_to, copy_backup_to

Something went wrong with that request. Please try again.