.zb-rc file support

This commit is contained in:
Mirek Kratochvil 2014-06-16 12:00:31 +02:00
parent 530cd735f9
commit ece4ab99df
4 changed files with 28 additions and 3 deletions

View file

@ -12,13 +12,23 @@ The zfs backing-up tool. ha-ha.
recent snapshots of `remote_zfs_object` to `local_zfs_object`, using ssh recent snapshots of `remote_zfs_object` to `local_zfs_object`, using ssh
called with `ssh_connection` called with `ssh_connection`
## Installation&requirements ## Requirements
`bash` shell and `zfs` utils are needed. `zb-pull` requires `ssh`. `bash` shell and `zfs` utils are needed. `zb-pull` requires `ssh`.
zfs-backup requires GNU `date` or compatible, other `date` programs may fail.
Test is simple, check if this command works for you:
date --date=now
## Installation
Run `make install`, it installs itself to some `sbin/`. You can also specify Run `make install`, it installs itself to some `sbin/`. You can also specify
`DESTDIR=/usr/local/` or similar. `DESTDIR=/usr/local/` or similar.
For local changes (command aliases/wrappers, `PATH` setting etc.), file
`$HOME/.zb-rc` is sourced before any commands are run.
## Example ## Example
$ zb-snap tank/test $ zb-snap tank/test
@ -78,7 +88,8 @@ And on remote backup machines:
- `zb-pull` every morning - `zb-pull` every morning
- `zb-cleanup` with a slightly higher density number (it keeps more backups) - `zb-cleanup` with a slightly higher density number (it keeps more backups)
### What exactly does zb-cleanup clean up? ## FAQ
#### What exactly does zb-cleanup clean up?
Candidates for backup deletion are determined like this: Candidates for backup deletion are determined like this:
@ -89,7 +100,7 @@ Candidates for backup deletion are determined like this:
3. Calculate `density*(Y-X)/Y`. If the result is less than 1.0, delete the 3. Calculate `density*(Y-X)/Y`. If the result is less than 1.0, delete the
_closer_ backup. _closer_ backup.
### How to determine your density and other numbers? #### How to determine your density and other numbers?
Density is "maximum ratio of time between backups to age of backups, in Density is "maximum ratio of time between backups to age of backups, in
percent". percent".
@ -113,6 +124,17 @@ Good approach to determine it (with all the other numbers) is this:
value from the second row - in our case, daily. (probably in morning or value from the second row - in our case, daily. (probably in morning or
somehow off-peak hours). somehow off-peak hours).
#### It doesn't work from cron!
Check if the environment is the same as when you test the stuff from the command line. At least two common caveats exist:
- `PATH` may be different in cron (which may select wrong `date` program to
run, or not find something other like custom-installed `zfs`). Edit
`~/.zb-rc` and fix `PATH` there.
- Some SSH authentication methods may not work from cron environment due to
missing `ssh-agent`, especially the password-protected privkeys. Descriptions
of many workarounds are available around the internet.
## Disclaimer ## Disclaimer
Be sure to verify that this software really fits your use-case before you use Be sure to verify that this software really fits your use-case before you use

View file

@ -1,6 +1,7 @@
#!/bin/bash #!/bin/bash
source /etc/profile >/dev/null source /etc/profile >/dev/null
[ -f "$HOME/.zb-rc" ] && source "$HOME/.zb-rc"
if [[ -z "$1" || -z "$2" ]] ; then if [[ -z "$1" || -z "$2" ]] ; then
echo "usage: $0 <zfs_object> <density_percent> [max_age]" >&2 echo "usage: $0 <zfs_object> <density_percent> [max_age]" >&2

View file

@ -1,6 +1,7 @@
#!/bin/sh #!/bin/sh
source /etc/profile >/dev/null source /etc/profile >/dev/null
[ -f "$HOME/.zb-rc" ] && source "$HOME/.zb-rc"
if [[ -z "$1" || -z "$2" || -z "$3" ]] ; then if [[ -z "$1" || -z "$2" || -z "$3" ]] ; then
echo "usage: $0 <ssh_remote> <remote_zfs_object> <local_zfs_object>" >&2 echo "usage: $0 <ssh_remote> <remote_zfs_object> <local_zfs_object>" >&2

View file

@ -1,6 +1,7 @@
#!/bin/sh #!/bin/sh
source /etc/profile >/dev/null source /etc/profile >/dev/null
[ -f "$HOME/.zb-rc" ] && source "$HOME/.zb-rc"
if [ -z "$1" ] ; then if [ -z "$1" ] ; then
echo "usage: $0 <zfs_object>" >&2 echo "usage: $0 <zfs_object>" >&2