BackupScripts

From HerzbubeWiki
Jump to navigation Jump to search

This page documents a couple of backup shell scripts that I am using to implement my backup solution.


Copy script

The script that creates a copy of a data set is

htb-mkbackupcopy.sh

I have made the script somewhat generic and added it to herzbube's toolbox, my personal collection of shell scripts. Here's a direct link to the latest version of the script.

The script uses rsync to copy a source folder to a destination folder. The source folder can be on a remote machine, the destination folder is either on a local filesystem, on a Samba share or on a disk image (which in turn can be located on a Samba share). Here's the script's usage text:

pi@raspberrypi1:~$ htb-mkbackupcopy.sh -h
htb-mkbackupcopy.sh [-h] [-i <pattern>] [-e <pattern>] [-s <samba-spec>] [-d <disk-image-path>] [[user@]host:]source destination
 -h: Print this usage text
 -i <pattern>: An include pattern to be passed to rsync.
   This parameter can be specified multiple times. The
   order in which include/exclude patterns are specified
   is important.
 -e <pattern>: An exclude pattern to be passed to rsync.
   This parameter can be specified multiple times. The
   order in which include/exclude patterns are specified
   is important.
 [-s <samba-spec>]: Specification of a Samba share to
   mount. The specification conforms to the usual syntax
   used by "mount -t smbfs" (see man "mount_smbfs").
 [-d <disk-image-path>]: The path to a disk image to
   mount. If -s is also specified, the path specified
   here must exist on the Samba share after it is
   mounted. The disk image can be anything that can be
   processed by hdiutil.
 [[user@]host:]source: Specification of source folder.
   Specification of remote source folder conforms to
   the usual rsync / SSH syntax.
 destination: Specification of destination folder. If
  -s is specified, the path specified here must exist
  on the Samba share after it is mounted. If -d is
  specified (regardless of whether -s is also specified),
  the path specified here must exist on the disk image
  after it is mounted.

Exit codes:
 0: No error
 2: Aborted by signal (e.g. Ctrl+C)
 3: Error during initialisation
 4: Error while checking arguments
 5: Error during main program


Snapshot script

The script that creates a snapshot of a data set is

htb-mkbackupsnapshot.sh

As with the copy script, I have made the snapshot script somewhat generic and added it to herzbube's toolbox. Here's a direct link to the latest version of the script.

The script uses bup to create a snapshot of a specified source folder. Both the source folder and the bup repository must be somewhere on a local file system. Here's the script's usage text:

pi@raspberrypi1:~$ htb-mkbackupsnapshot.sh -h
htb-mkbackupsnapshot.sh [-h] source bup-repository
 -h: Print this usage text
 source: Specification of folder to snapshot.
 bup-repository: Specification of the bup repository
   folder.

Exit codes:
 0: No error
 2: Aborted by signal (e.g. Ctrl+C)
 3: Error during initialisation
 4: Error while checking arguments
 5: Error during main program