SAFEKEEP.BACKUP(5)
πΈ SAFEKEEP.BACKUP(5) β the SafeKeep Client Configuration glow-up πΈ
okay bestie, this is safekeep.backup, the config file for a safekeep(1) client. it's giving "instructions for your backup bestie" and honestly? iconic.
β¨ NAME β¨
safekeep.backup β the configuration file for a safekeep(1) client. yes queen, that's literally her job.
π SYNOPSIS π
these files usually live in /etc/safekeep/backup.d/, or, if you're not root, optionally in ~/.safekeep/backup.d/ β that way safekeep(1) just picks them up automatically, no cap. and they must have a .backup extension. non-negotiable π
π¦ DESCRIPTION π¦
each config file controls the backup of like, one host. they're typically named after the hostname of the machine they're in charge of, plus the .backup extension (think mailbox.backup). these files are written in XML, bestie. XML. don't ask, it's a vibe.
virtually all elements and attributes are optional β if you skip them, safekeep(1) provides reasonable, useful defaults. so you can absolutely be lazy and it still slays. π«Ά
the full set of supported elements and attributes looks like this:
<backup id="my_workstation" enabled="true">
<!-- the client backup host, the user and keys for access -->
<host name="myhost" user="root" nice="10"
key-ctrl="/home/jdoe/.ssh/backup_id_rsa"
key-data="/home/jdoe/.ssh/backup2_id_rsa" />
<!-- rate limit bandwidth (kB/s) on a client basis -->
<bandwidth overall="80" download="50" upload="50" />
<!-- where to stored the data on the server, and for now long -->
<repo path="./data" retention="10D" />
<!-- set options affecting execution of rdiff-backup for this host -->
<options>
<!-- An option to run a different version of rdiff-backup locally, -->
<!-- say for compatibility with older systems -->
<!-- <rdiff-backup exec_local="rdiff-backup-1" /> -->
</options>
<!-- settings for database dump and for volume snapshot -->
<setup>
<!-- databases can be dumbed before the backup -->
<dump type="postgres" db="my_db" dbuser="foobar" options="--schema=public"
file="/var/backup/dumps/mydata" cleanup="true" />
<!-- what volume is to be snapshot, and the size of the snapshot -->
<snapshot device="/path/to/volume" size="500M" />
<!-- location of a script to be executed at different stages of the run -->
<script path="server:/path/to/script" />
</setup>
<!-- data to be backup -->
<data exclude-fifos="true" exclude-sockets="true">
<!-- each type of tag can be present more than one time -->
<!-- if a database dump was created, it must be added in this section -->
<include path="/home"/>
<exclude path="/home/guest"/>
<include glob="**/important/"/>
<exclude glob="/home/*/tmp"/>
<include regexp=".*\.ogg"/>
<exclude regexp=".*\.mp3"/>
</data>
</backup>
π PARAMETERS π
XML elements and attributes get referred to via XPath expressions: elements are separated by /, and attributes are introduced by @. it's giving file-path energy, iykyk.
/backupβ the root element of the XML file. mandatory, bestie. you literally cannot skip this one. π/backup/@idβ this is the ID thatsafekeep(1)uses to address this host. if you specify it, it overrides the default value derived from the filename. optional, defaults to the filename without the.backupextension. and pls, use of the default value is highly recommended. π₯°/backup/@enabledβ if specified and set tofalseor0, it disables this host. it's a nicer way to disable a host without renaming the file β no messy file renames, we love to see it. optional, defaults totrue./backup/host/@nameβ the name or IP address of the client. if you need to back up the box that the server is running from, you can set this to"localhost". and listen, this is different from leaving it blank β it will establish an SSH session and use the user specified by/backup/host/@user. optional, defaults to local access./backup/host/@portβ the network port to use when connecting to the client. it must be a number and it gets passed to the network connection agent, usually SSH. optional, defaults to not passing any port specification at all./backup/host/@userβ the user name to use when connecting to the client. this user must have read permissions for the files that will be backed up, so it most likely needs to beroot. like, it's basically always root. optional, defaults to the value given byclient.userinsafekeep.conf./backup/host/@niceβ the nice adjustment for the client. this setting is normally not all that important, since most of the load rests on the server side. NB: if you change this value, you will have to re-deploy the auth keys. optional, defaults to no nice level. π/backup/host/@key-ctrlβ the private key used to establish the SSH connection to the client for the control channel. use of the default value is recommended. optional, defaults to~/.ssh/safekeep-server-ctrl-key./backup/host/@key-dataβ the private key used to establish the SSH connection to the client for the data channel. use of the default value is recommended. optional, defaults to~/.ssh/safekeep-server-data-key./backup/bandwidth/@overallβ the client bandwidth limit for both upload and download. it's an integer number of KB/s (peep the NOTES section insafekeep.conf(5)for more info, bestie). optional, and it overridesbandwidth.overallinsafekeep.conf(5)if specified./backup/bandwidth/@downloadβ the client bandwidth limit for download (see/backup/bandwidth/@overallfor more info). optional, overrides/backup/bandwidth/@overallif specified./backup/bandwidth/@uploadβ the client bandwidth limit for upload (see/backup/bandwidth/@overallfor more info). optional, overrides/backup/bandwidth/@overallif specified./backup/repo/@pathβ the path under which the backups will be stored. relative paths are based on thebase.dirsetting fromsafekeep.conf(5). since the default value forbase.diris the user's home directory, in a typical installation the data will be stored under/var/lib/safekeep/<id>/. if the directory does not exist,safekeep(1)will attempt to create it automatically β and the backup will fail altogether if the directory can not be created. optional, defaults to the client ID, see/backup/@id. use of the default value is highly recommended.
β οΈ NOTE: if you must set this value explicitly, you must make sure that the path is not shared between different boxes β a shared repository path will result in data loss. like, actual data loss. not cute. π
/backup/repo/@retentionβ specifies the duration for which the backup data will be retained. the incremental backup information in the destination directory that has been around longer than the retention time will be removed. the value specified by this attribute is a time interval: an integer followed by the characters,m,h,D,W,M, orY, indicating seconds, minutes, hours, days, weeks, months, or years respectively β or a number of these concatenated. for example,32mmeans 32 minutes, and3W2D10h7smeans 3 weeks, 2 days, 10 hours, and 7 seconds. in this context, a month means 30 days, a year is 365 days, and a day is always 86400 seconds.
note that backups of deleted files are covered by this operation. so if you deleted a file two weeks ago, backed up immediately afterward, and then ran safekeep(1) with a retention of 10D today, no trace of that file would remain. gone. poof. π¦
finally, file selection options don't affect removal of incremental data. optional, defaults to empty (unlimited retention).
/backup/options/special-files/@includeβ NOTE: THIS OPTION HAS BEEN DEPRECATED. go look at thedataattributes below instead, bestie. one of"true"or"false". if"true", the dump file will include all special files, including device files, fifo files and socket files. optional, defaults tofalse.
NOTE: specification of no options is equivalent to false, but the inclusion of other options may cause the underlying backup defaults to be use. (yes, "to be use". we don't fix it, we respect it. π
)
/backup/options/rdiff-backup/@appendβ append the specified options to the current rdiff-backup run. this is planned to be specific to the current rdiff-backup, and different options will be made available for other backends./backup/options/rdiff-backup/@exec_localβ executable to be run on the local host. optional, defaults tordiff-backup./backup/options/rdiff-backup/@exec_remoteβ executable to be run on the remote host. optional, defaults tordiff-backup./backup/setup/@writableβ a boolean (i.e."true"or"false") to set mount as writable or not, including snapshots and bind mounts. this is normally not required, and, if set, overrides the system default β but it is overridden by a snapshot option. in general the system default is to create non-writable mount for both snapshots and bind mounts. optional for a<setup>element./backup/setup/dump/@typeβ one of"postgres"or"mysql". mandatory for a<dump>element. pick one, babe. π/backup/setup/dump/@dbβ name of the database to dump. if not specified, it defaults to all databases maintained in the RDBMS specified bytype. optional, defaults to all databases./backup/setup/dump/@save-db-nameβ specify ifCREATE DATABASEinstructions are included in database dumps. if the option is not specified then the result defaults to what is natural for the default database dump function. if the option is"true"thenCREATE DATABASEare added in all cases. if the option is"false"then noCREATE DATABASEstatement is added.
NOTE: for Postgres it is not possible to suppress the CREATE DATABASE statement when dumping all databases, i.e. no single database named, in which case this option is ignored. optional, defaults to not set.
/backup/setup/dump/@dbuserβ name of the database user to use while doing the dump. optional, defaults to whatever the database determines based on the system user./backup/setup/dump/@dbpasswdβ password of the database user to use while doing the dump.
π¨ NB: this makes the DB password available in a plain text file. make sure you use appropriate read permissions on the backup configuration file to prevent unauthorized access to the password. like please. for me. π
optional, it has no default value.
/backup/setup/dump/@optionsβ extra options to be passed along to the dump command. this is database specific, and it is passed along as-is. please refer to your database documentation for possible values that you can pass along. optional, it has no default value./backup/setup/dump/@userβ the system user the dump runs as, bestie. Heads up tho: using this meanssafekeep(1)has to be running as root on the client π€. Optional, and it defaults to whichever usersafekeep(1)is running as on the client side π/backup/setup/dump/@fileβ the full path to the dump file over on the client host. This one's mandatory for a<dump>element, no skipping π ββοΈ/backup/setup/dump/@cleanupβ either"true"or"false". If it's"true", the dump file gets yeeted off the client system once the backup is done ποΈ. Ngl it's usually pointless to delete it, since it'll just get created again for every single backup β so like, you need the space either way. Optional, defaults tofalse./backup/setup/snapshot/@deviceβ the path (device location) of the client LVM volume we snapshot before the backup kicks off. Important: the snapshot happens on the client machines, and it keeps your data in a consistent state for the whole backup process β¨. You can specify multiple snapshots β and the order matters, the associated filesystems get mounted in the order you give them π. Also: this feature needssafekeep(1)running as root on the client. Mandatory for a<snapshot>element./backup/setup/snapshot/@sizeβ how big the snapshot is. There must be unallocated space on the volume group. Highly recommend making it like 15-20% of the original device's size π. You can give it as a percentage, e.g.20%, which is literally 20% of the logical volume. Other values as listed forlvcreate(8)work too. Optional, defaults tosnapshot.sizeas specified insafekeep.conf./backup/setup/snapshot/@tagβ a list of tags to slap on the snapshot, via the--addtagargument tolvcreate(8)π·οΈ. The@tagentry is a,-separated list of tags, and an@gets automatically added to each generated tag. Optional for a<snapshot>element./backup/setup/snapshot/@mountoptionsβ mount options used with the snapshot device. Normally you don't need this, the defaults suit routine usage π. Optional for a<snapshot>element./backup/setup/snapshot/@writableβ a boolean (so,"true"or"false") setting whether the snapshot mount is writable or not. Normally not required, and if you do set it, it overrides other settings from the setup option or the system default π. Optional for a<snapshot>element./backup/setup/script/@pathβ runs the script at this path on the client or server at certain steps of the backup process. It gets executed with four arguments:- Backup id (
/backup/@id) - Backup step
- Backup root directory (valid after creation of a snapshot) for client, or the safekeep backup directory for server
- Run-on parameter, i.e.
clientorserver
- Backup id (
For client-side scripts, the location optionally consists of an optional host plus a mandatory path, separated by a ":", where the host part is either "client" or "server". If you don't specify a host part, it's first looked for on the client, and if it's not found there, then it's looked for on the server. If it's not found on either, a warning gets raised π¨. Only one <script> element may be specified. See the CLIENT AND SERVER SCRIPTS section for more. Mandatory for a <script> element.
/backup/setup/script/@run-onβ run the script on the"server"or the"client". Optional, defaults toclientπ«Ά/backup/data/@exclude-devicesβ one of"true"or"false". If"true", the dump file excludes all device files. Optional, defaults tofalse. NOTE: specifying no attributes is equivalent tofalse, but the inclusion of other options may cause the underlying backup defaults to be used π/backup/data/@exclude-fifosβ one of"true"or"false". If"true", the dump file excludes all fifos. Optional, defaults tofalse. NOTE: specifying no attributes is equivalent tofalse, but the inclusion of other options may cause the underlying backup defaults to be used π/backup/data/@exclude-socketsβ one of"true"or"false". If"true", the dump file excludes all sockets. Optional, defaults tofalse. NOTE: specifying no attribute is equivalent tofalse, but the inclusion of other options may cause the underlying backup defaults to be used π/backup/data/exclude/@pathβ excludes the file or files matched by the path. If a directory gets matched, then the files under that directory are matched too π¦. See the FILE SELECTION section for more./backup/data/include/@pathβ includes the file or files matched by the path. If a directory gets matched, then the files under that directory are matched too π¦. See the FILE SELECTION section for more./backup/data/exclude/@globβ excludes the file or files matched by the shell pattern. If a directory gets matched, then the files under that directory are matched too πΈ. See the FILE SELECTION section for more./backup/data/include/@globβ includes the file or files matched by the shell pattern. If a directory gets matched, then the files under that directory are matched too πΈ. See the FILE SELECTION section for more./backup/data/exclude/@regexpβ excludes the file or files matched by the regular expression. If a directory gets matched, then the files under that directory are matched too π. See the FILE SELECTION section for more./backup/data/include/@regexpβ includes the file or files matched by the regular expression. If a directory gets matched, then the files under that directory are matched too π. See the FILE SELECTION section for more.
π FILE SELECTION π
Okay so safekeep(1) does file selection kinda like rdiff-backup(1) does β iconic behavior, honestly. When rdiff-backup runs, it searches through the source directory you gave it and backs up all the files specified by the file selection system β¨.
That file selection system is made up of a bunch of file selection conditions, which you set using one of the <include>/<exclude> elements. Each condition either matches or doesn't match a given file. A file gets included or excluded by the system when the first matching condition says include or exclude respectively β first match wins, periodt π
. And if a file matches no include or exclude statement at all? It's excluded by default. Sorry babe π.
When backing up, if a file is excluded, safekeep(1) acts like that file straight up doesn't exist in the source directory π.
For more on file selection semantics, please see rdiff-backup(1) β the lore is all there π.
π CLIENT AND SCRIPTS π
safekeep(1) supports optionally executing a script or program on the client or server systems at different steps while the backup is running πββοΈπ¨.
Right now, only a single script β either client-side or server-side β can be specified for a client.
For client-side scripts, the script may live on either the server or the client. If it's on the server, then the file gets copied over to the client into a temporary directory before it runs. Note that this directory lives wherever the system normally creates temporary files, and it's possible that executing scripts is disallowed there π¬. In that case, the recommendation is to use a client-based script instead. Also, the script is copied from the server line by line, so it is not suitable for passing binary files. Bestie. Do not. π
For server-side scripts, the script must be located on the server. Simple as that π«Ά.
Note: specifying a script that doesn't exist is not considered an error β it's treated the same as not specifying a script at all. However, if the specified path does match a file or directory, the security tests listed below will run π
This script is executed with the following four arguments:
- Safekeep step
- Backup id
- Backup root directory, which may be set during the creation of a snapshot for client, or the safekeep backup directory for server
- Run-on parameter, i.e.
clientorserver
For both client-side and server-side scripts, the steps currently defined and the tokens passed are:
STARTUPβ prior to any execution. But if it exits with a non-zero status, that constitutes an error and the backup is aborted π.PRE-SETUPβ prior to running any setup steps. A non-zero status is considered a warning and execution continues.POST-SETUPβ after setup, but prior to execution of the backup. A non-zero status is considered a warning, and execution continues.POST-BACKUPβ after execution of the backup. A non-zero status is considered a warning, and execution continues.POST-SCRUBβ after execution of a server cleanup step, normally only seen after a backup failure. A non-zero status is considered a warning, and execution continues.
Due to security considerations, a number of checks are made on this script prior to execution, and failure of any of these steps will cause the backup for that client to be aborted π€. The following tests are applied prior to each execution of the script (so like, multiple times per backup), in order:
- script is a regular file, not a directory or special file
- script is executable by the user running on the client system
- script is owned by root or the user running on the client system
- script is NOT writable by anyone except the script owner
Note: no test is made on the ownership of the parent directory or any other directories. Just so you know π
ποΈ FILES ποΈ
/etc/safekeep/backup.d/
~/.safekeep/backup.d/
π SEE ALSO π
safekeep(1), safekeep.conf(5), rdiff-backup(1), lvcreate(8)
π AUTHOR π
This man page was originally written by Dimi Paun <dimi@lattica.com[1]>. Thank you Dimi, we love you fr fr π«Ά
π NOTES π
dimi@lattica.commailto:dimi@lattica.com
And that's the whole vibe check bestie β this is safekeep, dated 09/10/2023, and you just read SAFEKEEP.BACKUP(5) β¨π Go forth and back up responsibly, mwah π
π¦ where this page comes from
- epel 9: safekeep-server 1.5.1^20230910git75e66fe-1.el9 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms