MagiBackup is a backup utility that allows flexible mirroring to external backup drives mounted on multiple hosts.
Features:
-
Declarative configuration in Python
-
Define includes and excludes
-
Backup to local and remote hosts
-
Finds out which drives are mounted on which hosts. This is handy with portable drives.
-
Automatically unmount volumes after backup. This is also handy with portable drives.
Not implemented yet:
-
There is preliminary support for encrypted volumes. You just need to mount the drive and the encrypted volumes are mounted automatically.
There is currently no installation package.
You just need to copy the bin/magibackup
program to shell path, such as to /usr/local/bin
.
You need to create a configuration file as described next.
You can find an example configuration file in conf/magibackuprc.py
.
You need to have a ~/.backup/magibackuprc.py
file, where you define the hosts, drives, and
backup plans.
You need to define a list of hosts where the drives can be mounted.
hosts = [LocalHost(mountroot="/media"),
RemoteHost("otherhostname", mountroot="/media/myuserid")]
Each backup drive must be listed as a Drive object in the drives
list.
The drive definitions include the backups that can be done to the drive.
The first parameter defines the drive ID by which it is expected to be mounted.
The other parameters are:
volumes
-
List of drive volumes to be mounted. See Volume Definition.
hosts
-
List of hosts where this drive can be mounted. The hosts are identified by their hostnames.
backups
-
List of backups to be done to the drive. See Backup Definition.
For example:
drives = [Drive("SG2TB2016",
volumes = [PlainVolume("/"),
# Not supported currently
CryptVolume("/.encfs", "/mirror", "password123")],
hosts = ["localhost", "otherhostname"],
backups = [
Backup(["/home/myuserid/video"],
target = "/",
excludes = ["*~", "*/4k/*"])
])]
See more examples in the magibackuprc.py
configuration template.
Volume types are:
- PlainVolume
-
Unencrypted volume. The first parameter gives the relative path to the mount point. For example, if
mountroot
is/media
and the relative path is/
, the plain volume defined in the following configuration would be mounted at/media/SG2TB2016
. - CryptVolume
-
EncFS encrypted volume. Not implemented yet.
Each backup must be listed as a Backup object in the backups
list.
The first parameter for the constructor is a list of source directories that are to be backed up.
Other parameters are:
target
-
Target directory relative to the mount point of the drive.
backupdir
(optional)-
Backup directory for storing deleted or old versions of changed files. The path is relative to the mount point of the drive. Folder with (daily) timestamp will appended to the path in the ISO format, that is,
yyyy-mm-dd
.For example:
backupdir = "/mirror/deleted"
. excludes
(optional)-
Filename patterns to be excluded from the backup. The pattern syntax is the rsync exclude pattern syntax.
The utility does not currently mount the backup drives. You must mount them manually.
You can autodetect the presence of drives on different hosts by running the utility without parameters.
$ magibackup Available drives: SG2TB2016 on localhost WDMB4T2016 on otherhost WD3TB2012 on KtonmDuo32G on localhost
To make backups to a drive:
$ magibackup WDMB4T2016