zsync/README.md

87 lines
2.5 KiB
Markdown
Raw Normal View History

2024-02-08 00:40:42 +01:00
---- THIS IS A CLONE OF THE ORIGINAL REPOSITORY ON git.bashclub.org ----
2024-02-07 23:48:52 +01:00
2024-02-08 00:40:42 +01:00
# zsync
2024-02-07 23:48:52 +01:00
2024-02-08 00:40:42 +01:00
ZFS replication script by Thorsten Spille <thorsten@spille-edv.de>
- replicates ZFS filesystems/volumes with user parameter bashclub:zsync (or custom name) configured
- creates optional snapshot before replication (required zfs-auto-znapshot)
- parameter setting uses zfs hierarchy on source
- mirrored replication with existing snapshots (filtered by snapshot_filter)
- pull/local replication only
- auto creates full path on target pool, enforce com.sun:auto-snapshot=false, inherits mountpoint and sets canmount=noauto
- raw replication
- tested on Proxmox VE 7.x/8.x
- ssh cipher auto selection
2024-02-07 23:48:52 +01:00
2024-02-08 00:40:42 +01:00
## Installation
2024-02-07 23:48:52 +01:00
2024-02-08 00:40:42 +01:00
#### Download and make executable
~~~
wget -q --no-cache -O /usr/bin/bashclub-zsync https://git.bashclub.org/bashclub/zsync/raw/branch/dev/bashclub-zsync/usr/bin/bashclub-zsync
chmod +x /usr/bin/bashclub-zsync
bashclub-zsync
~~~
2024-02-07 23:48:52 +01:00
2024-02-08 23:50:12 +01:00
## Documentation
[DOCUMENTATION_DE.md](DOCUMENTATION_DE.md)
2024-02-08 00:40:42 +01:00
## Configuration
After first execution adjust the default config file `/etc/bashclub/zsync.conf`:
2024-02-07 23:48:52 +01:00
2024-02-08 00:40:42 +01:00
~~~
2024-02-08 23:50:12 +01:00
# replication target path on local machine
target=pool/dataset
2024-02-07 23:48:52 +01:00
2024-02-08 23:50:12 +01:00
# ssh address of remote machine
2024-02-08 00:40:42 +01:00
source=user@host
2024-02-07 23:48:52 +01:00
2024-02-08 23:50:12 +01:00
# ssh port of remote machine
2024-02-08 00:40:42 +01:00
sshport=22
2024-02-07 23:48:52 +01:00
2024-02-08 23:50:12 +01:00
# zfs user parameter to identify filesystems/volumes to replicate
2024-02-08 00:40:42 +01:00
tag=bashclub:zsync
2024-02-07 23:48:52 +01:00
2024-02-08 23:50:12 +01:00
# pipe separated list of snapshot name filters
2024-02-08 00:40:42 +01:00
snapshot_filter="hourly|daily|weekly|monthly"
2024-02-07 23:48:52 +01:00
2024-02-08 23:50:12 +01:00
# minimum count of snapshots per filter to keep
2024-02-08 00:40:42 +01:00
min_keep=3
2024-02-07 23:48:52 +01:00
2024-02-08 23:50:12 +01:00
# number of zfs snapshots to keep on source (0 or 1 = snapshot function disabled)
2024-02-08 00:40:42 +01:00
zfs_auto_snapshot_keep=0
2024-02-07 23:48:52 +01:00
2024-02-08 00:40:42 +01:00
# make snapshot via zfs-auto-snapshot before replication
zfs_auto_snapshot_label="backup"
2024-02-07 23:48:52 +01:00
2024-02-08 23:50:12 +01:00
# disable checkzfs with value > 0
checkzfs_disabled=0
# set checkzfs parameter "--prefix"
checkzfs_prefix=zsync
# set checkzfs maximum age of last snapshot in minutes (comma separated => warn,crit)
checkzfs_max_age=1500,6000
# set checkzfs maximum count of snapshots per dataset (comma separated => warn,crit)
checkzfs_max_snapshot_count=150,165
2024-02-08 00:40:42 +01:00
~~~
2024-02-07 23:48:52 +01:00
2024-02-08 00:40:42 +01:00
### Define a cronjob
#### cron.d example
File: /etc/cron.d/bashclub-zsync
~~~
00 23 * * * root /usr/bin/bashclub-zsync -c /etc/bashclub/zsync.conf > /var/log/bashclub-zsync/zsync.log
~~~
2024-02-07 23:48:52 +01:00
2024-02-08 00:40:42 +01:00
#### cron.{hourly|daily|weekly|monthly}
File: /etc/cron.hourly/bashclub-zsync
~~~
/usr/bin/bashclub-zsync -c /etc/bashclub/zsync.conf > /var/log/bashclub-zsync/zsync.log
~~~
2024-02-07 23:48:52 +01:00
2024-02-08 00:40:42 +01:00
# Author
2024-02-07 23:48:52 +01:00
2024-02-08 00:40:42 +01:00
### Thorsten Spille
[<img src="https://storage.ko-fi.com/cdn/brandasset/kofi_s_tag_dark.png" rel="Support me on Ko-Fi">](https://ko-fi.com/thorakel)