dsnap-sync: rename project and introduce the fork
o distict the dash version from original work of Wes Barnett o circumvit any name clashes
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,4 +1,5 @@
|
||||
*~
|
||||
*.bak
|
||||
pkg/*
|
||||
*.tar*
|
||||
*.gz
|
||||
|
||||
78
README.md
78
README.md
@@ -1,11 +1,11 @@
|
||||
<!-- snap-sync README.md -->
|
||||
<!-- version: 0.5.1 -->
|
||||
<!-- dsnap-sync README.md -->
|
||||
<!-- version: 0.5.2 -->
|
||||
|
||||
# snap-sync
|
||||
# dsnap-sync
|
||||
|
||||
## About
|
||||
|
||||
`snap-sync` is implemented as a posix shell script.
|
||||
`dsnap-sync` is implemented as a posix shell script (dash).
|
||||
It takes advantage of the specific functionality of a btrfs file system and
|
||||
makes it possible to backup data while sending incremental snapshots to another
|
||||
drive. It's fine to store to dives on a remote host (using ssh).
|
||||
@@ -13,22 +13,24 @@ drive. It's fine to store to dives on a remote host (using ssh).
|
||||
Plug in and mount any btrfs-formatted device you want your system to be
|
||||
backed up to (eg. local USB drive, remote RAID drives).
|
||||
|
||||
`snap-sync` will support interactive an time scheduled backup runs.
|
||||
`dsnap-sync` will support interactive an time scheduled backup runs.
|
||||
|
||||
* An interactive run will request you to select a mounted btrfs device.
|
||||
You can pre-select the target drive via [command line options](https://github.com/wesbarnett/snap-sync#options).
|
||||
You can pre-select the target drive via [command line options](https://github.com/wesbarnett/dsnap-sync#options).
|
||||
Either use the UUID, the SUBVOLID or it's TARGET (read 'mount point').
|
||||
|
||||
* A scheduled run will take all needed parameters from config options.
|
||||
|
||||
For a backup run, `snap-sync` will iterate through all defined snapper configurations
|
||||
For a backup run, `dsnap-sync` will iterate through all defined snapper configurations
|
||||
found on your source system. If you prefer to just run on a specific configuration,
|
||||
you can select this using the 'config' option `-c`. For each selected configuration
|
||||
it will use snapper to create an appropriate local snapshot.
|
||||
|
||||
We do also support systemd.timer units. Please refer to related paragraph below.
|
||||
|
||||
## Requirements
|
||||
|
||||
`snap-sync`relies on external tools to achieve its goal.
|
||||
`dsnap-sync`relies on external tools to achieve its goal.
|
||||
At run-time their availability is checked. Following tools are are used:
|
||||
|
||||
- snapper
|
||||
@@ -47,14 +49,14 @@ configuration file, specify it on the command line with
|
||||
# make SNAPPER_CONFIG=/etc/conf.d/snapper install
|
||||
|
||||
The local snapper configuration will be extended to make use
|
||||
of a new template 'snap-sync'.
|
||||
of a new template 'dsnap-sync'.
|
||||
|
||||
The package is also available in the
|
||||
[AUR](https://aur.archlinux.org/packages/snap-sync/).
|
||||
[AUR](https://aur.archlinux.org/packages/dsnap-sync/).
|
||||
|
||||
## Options
|
||||
|
||||
Usage: snap-sync [options]
|
||||
Usage: dsnap-sync [options]
|
||||
|
||||
Options:
|
||||
-d, --description <desc> Change the snapper description. Default: "latest incremental backup"
|
||||
@@ -77,7 +79,7 @@ The package is also available in the
|
||||
|
||||
## First run
|
||||
|
||||
If you have never synced to the paticular target device (first run), `snap-sync`
|
||||
If you have never synced to the paticular target device (first run), `dsnap-sync`
|
||||
will take care to create the necessary target file-structure to store the snapshot.
|
||||
As an option you can prepend a backup-path.
|
||||
|
||||
@@ -86,33 +88,33 @@ You have to confirm any further operation, or use defaults (option: noconfirm).
|
||||
|
||||
## Example command line usage
|
||||
|
||||
### Snap-sync to local target
|
||||
### dsnap-sync to local target
|
||||
|
||||
#### Default: no selections, run for all snapper configs
|
||||
|
||||
# snap-sync
|
||||
# dsnap-sync
|
||||
|
||||
#### Default: Select two configs, the backupdir and verbose output
|
||||
|
||||
# snap-sync --verbose --config root --config data2 --backupdir=toshiba_r700
|
||||
# dsnap-sync --verbose --config root --config data2 --backupdir=toshiba_r700
|
||||
|
||||
#### Dry-run: Select config, select Target, as batchjob (--noconfirm)
|
||||
|
||||
# snap-sync -c root -s 265 --noconfirm --dry-run
|
||||
# dsnap-sync -c root -s 265 --noconfirm --dry-run
|
||||
|
||||
|
||||
### Snap-sync to remote host
|
||||
### dsnap-sync to remote host
|
||||
|
||||
`snap-sync` will rely on ssh access to the target host. For batch usage make sure, that your
|
||||
`dsnap-sync` will rely on ssh access to the target host. For batch usage make sure, that your
|
||||
public key is accepted for remote login as user 'root'. You may have to adapt /root/.ssh/authorized_keys
|
||||
on the target host.
|
||||
|
||||
On your target host, you should also verify the availability of a snap-sync config-template for snapper.
|
||||
A template `snap-sync` is included in the package for your convenience.
|
||||
On your target host, you should also verify the availability of a dsnap-sync config-template for snapper.
|
||||
A template `dsnap-sync` is included in the package for your convenience.
|
||||
|
||||
#### Dryrun: Select remote host <ip/fqdn>, interactive, run for all configs
|
||||
|
||||
snap-sync --dry-run --remote 172.16.0.3
|
||||
dsnap-sync --dry-run --remote 172.16.0.3
|
||||
Selecting a mounted BTRFS device for backups on 172.16.0.3.
|
||||
0) / (uuid=5af3413e-59ea-4862-8cff-304afe25420f,subvolid=257,subvol=/root)
|
||||
1) /.snapshots (uuid=5af3413e-59ea-4862-8cff-304afe25420f,subvolid=258,subvol=/@snapshots-root)
|
||||
@@ -125,7 +127,7 @@ A template `snap-sync` is included in the package for your convenience.
|
||||
8) /data (uuid=2ba04452-74aa-44df-b1c7-74e0a70c6543,subvolid=257,subvol=/data)
|
||||
9) /var/lib/machines/.snapshots (uuid=2ba04452-74aa-44df-b1c7-74e0a70c6543,subvolid=2121,subvol=/@snapshots-machines)
|
||||
10) /data/.snapshots (uuid=2ba04452-74aa-44df-b1c7-74e0a70c6543,subvolid=258,subvol=/@snapshots-data)
|
||||
11) /var/lib/snap-sync (uuid=753eba7a-41ce-49e0-b2e3-24ee07811efd,subvolid=420,subvol=/snap-sync)
|
||||
11) /var/lib/dsnap-sync (uuid=753eba7a-41ce-49e0-b2e3-24ee07811efd,subvolid=420,subvol=/dsnap-sync)
|
||||
x) Exit
|
||||
Enter a number: 11
|
||||
|
||||
@@ -134,26 +136,26 @@ A template `snap-sync` is included in the package for your convenience.
|
||||
|
||||
#### Sync: Select config 'data2', remote host <ip/fqdn>, target '/data', as batchjob (--noconfirm)
|
||||
|
||||
# snap-sync --config data2 --remote 172.16.0.3 --target /data --noconfirm
|
||||
# dsnap-sync --config data2 --remote 172.16.0.3 --target /data --noconfirm
|
||||
|
||||
## systemd example
|
||||
|
||||
### service
|
||||
|
||||
[Unit]
|
||||
Description=Run snap-sync backup
|
||||
Description=Run dsnap-sync backup
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/usr/bin/snap-sync --UUID 7360922b-c916-4d9f-a670-67fe0b91143c --subvolid 5 --noconfirm
|
||||
ExecStart=/usr/bin/dsnap-sync --UUID 7360922b-c916-4d9f-a670-67fe0b91143c --subvolid 5 --noconfirm
|
||||
|
||||
### timer
|
||||
|
||||
[Unit]
|
||||
Description=Run snap-sync weekly
|
||||
Description=Run dsnap-sync weekly
|
||||
|
||||
[Timer]
|
||||
OnCalendar=weekly
|
||||
@@ -166,11 +168,11 @@ A template `snap-sync` is included in the package for your convenience.
|
||||
## snapper template
|
||||
|
||||
###
|
||||
# template for snap-sync handling
|
||||
# template for dsnap-sync handling
|
||||
###
|
||||
|
||||
# subvolume to snapshot
|
||||
SUBVOLUME="/var/lib/snap-sync"
|
||||
SUBVOLUME="/var/lib/dsnap-sync"
|
||||
|
||||
# filesystem type
|
||||
FSTYPE="btrfs"
|
||||
@@ -201,13 +203,24 @@ A template `snap-sync` is included in the package for your convenience.
|
||||
# use systemd.timer for cleanup
|
||||
TIMELINE_CLEANUP="no"
|
||||
|
||||
# snap-sync as timer unit
|
||||
# dsnap-sync as timer unit
|
||||
SNAP_SYNC_EXCLUDE="yes"
|
||||
|
||||
## Contributing
|
||||
|
||||
Help wanted! Feel free to fork and issue a pull request to add features or
|
||||
tackle an open issue.
|
||||
Help is very welcome! Feel free to fork and issue a pull request to add features or
|
||||
tackle open issues.
|
||||
|
||||
## Related projects
|
||||
|
||||
I did fork from Wes Barnetts original work and wanted that to be merged back.
|
||||
Beside the fact that this version doesn't use any bashisms, Wes did let me know,
|
||||
that he doesn't have the time to review the changes appropriately to make it a merge.
|
||||
Anyone willing to do so is invided.
|
||||
|
||||
Until that date, i will offer this fork for the public. To overcome any name clashes
|
||||
i renamed this work to dsnap-sync.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
@@ -219,4 +232,5 @@ This work is licensed under a [Creative Common License 4.0][License-CC_BY]
|
||||
|
||||
![Creative Common Logo][Logo-CC_BY]
|
||||
|
||||
© 2016, 2017 James W. Barnett, Ralf Zerres
|
||||
© 2016, 2017 James W. Barnett
|
||||
© 2017 - 2018 Ralf Zerres
|
||||
|
||||
12
TODO
12
TODO
@@ -1,12 +0,0 @@
|
||||
# snap-sync TODO #
|
||||
|
||||
## open tasks ##
|
||||
|
||||
- snap-sync: introduce snapper function: important snapshots
|
||||
Important snapshots have important=yes in the userdata
|
||||
|
||||
## finished tasks ##
|
||||
|
||||
- snap-sync: refine paramteter parsing
|
||||
- snap-sync: refine functions structure
|
||||
- snap-sync: rport as posix compatible
|
||||
@@ -1,7 +1,7 @@
|
||||
#! /bin/sh
|
||||
|
||||
# snap-sync
|
||||
# https://github.com/wesbarnett/snap-sync
|
||||
# dsnap-sync
|
||||
# https://github.com/rzerres/dsnap-sync
|
||||
# Copyright (C) 2016, 2017 James W. Barnett
|
||||
# Copyright (C) 2017, 2018 Ralf Zerres
|
||||
|
||||
@@ -32,7 +32,7 @@ version="0.5.2.2"
|
||||
# The following lines are modified by the Makefile or
|
||||
# find_snapper_config script
|
||||
#SNAPPER_CONFIG=/etc/conf.d/snapper
|
||||
SNAPPER_CONFIG=/etc/default/snapper
|
||||
SNAPPER_CONFIG=/etc/conf.d/snapper
|
||||
SNAPPER_TEMPLATE_DIR=/etc/snapper/config-templates
|
||||
SNAPPER_CONFIG_DIR=/etc/snapper/configs
|
||||
|
||||
@@ -61,7 +61,7 @@ selected_uuid='none'
|
||||
selected_target='none'
|
||||
selected_subvol='none'
|
||||
snapper_snapshots=".snapshots" # hardcoded in snapper
|
||||
snapper_snapsync_template="snap-sync"
|
||||
snapper_snapsync_template="dsnap-sync"
|
||||
|
||||
###
|
||||
# functions
|
||||
@@ -443,9 +443,9 @@ parse_params () {
|
||||
. $SNAPPER_CONFIG
|
||||
selected_configs=${selected_configs:-$SNAPPER_CONFIGS}
|
||||
|
||||
snap_description_finished=${snap_description_finished:-"snap-sync backup"}
|
||||
snap_description_running=${snap_description_running:-"snap-sync in progress"}
|
||||
snap_description_synced=${snap_description_synced:-"snap-sync last incremental"}
|
||||
snap_description_finished=${snap_description_finished:-"dsnap-sync backup"}
|
||||
snap_description_running=${snap_description_running:-"dsnap-sync in progress"}
|
||||
snap_description_synced=${snap_description_synced:-"dsnap-sync last incremental"}
|
||||
|
||||
uuid_cmdline=${uuid_cmdline:-"none"}
|
||||
target_cmdline=${target_cmdline:-"none"}
|
||||
@@ -500,7 +500,7 @@ run_config () {
|
||||
# Pseudo Arrays $i -> store associated elements of selected_config
|
||||
i=0
|
||||
for selected_config in $selected_configs; do
|
||||
# only process existing snap-sync configurations
|
||||
# only process existing dsnap-sync configurations
|
||||
if [ ! -f "/etc/snapper/configs/$selected_config" ]; then
|
||||
die "Selected snapper configuration '$selected_config' does not exist."
|
||||
else
|
||||
@@ -1035,7 +1035,7 @@ select_target_disk () {
|
||||
set_config(){
|
||||
local config=${1:-/etc/snapper/config-templates/"$snapper_snapsync_template"}
|
||||
local config_key=${2:-SUBVOLUME}
|
||||
local config_value=${3:-/var/lib/snap-sync}
|
||||
local config_value=${3:-/var/lib/dsnap-sync}
|
||||
|
||||
if [ -n "$remote" ]; then
|
||||
$ssh sed -i \'"s#^\($config_key\s*=\s*\).*\$#\1\"$config_value\"#"\' $config
|
||||
@@ -1067,10 +1067,10 @@ Usage: $progname [options]
|
||||
Options:
|
||||
-b, --backupdir <prefix> backupdir is a relative path that will be appended to target backup-root
|
||||
-d, --description <desc> Change the snapper description. Default: "latest incremental backup"
|
||||
--label-finished <desc> snapper description tagging successful jobs. Default: "snap-sync backup"
|
||||
--label-running <desc> snapper description tagging active jobs. Default: "snap-sync in progress"
|
||||
--label-finished <desc> snapper description tagging successful jobs. Default: "dsnap-sync backup"
|
||||
--label-running <desc> snapper description tagging active jobs. Default: "dsnap-sync in progress"
|
||||
--label-synced <desc> snapper description tagging last synced jobs.
|
||||
Default: "snap-sync last incremental"
|
||||
Default: "dsnap-sync last incremental"
|
||||
-c, --config <config> Specify the snapper configuration to use. Otherwise will perform for each snapper
|
||||
configuration. Can list multiple configurations within quotes, space-separated
|
||||
(e.g. -c "root home").
|
||||
@@ -1124,10 +1124,10 @@ verify_snapper_structure () {
|
||||
printf "Create new snapper capable BTRFS subvolume '%s:%s' ...\n" "$remote_host" "$backup_root/$snapper_config"
|
||||
fi
|
||||
if [ ! "$dryrun" ]; then
|
||||
# verify that we can use a snap-sync aware template
|
||||
# verify that we can use a dsnap-sync aware template
|
||||
if $ssh [ ! -f $SNAPPER_TEMPLATE_DIR/$snapper_snapsync_template ]; then
|
||||
printf "A snapper template %s to configure the snapper subvolume %s is missing in %s on %s.\n" "$snapper_snapsync_template" "$snapper_config" "$SNAPPER_TEMPLATE_DIR" "$remote_host"
|
||||
printf "Did you miss to install the snap-sync's default snapper template on %s?\n" "$remote"
|
||||
printf "Did you miss to install the dsnap-sync's default snapper template on %s?\n" "$remote"
|
||||
die "snapper template %s to configure the snapper subvolume %s is missing in %s on %s.\n" "$snapper_snapsync_template" "$snapper_config" "$SNAPPER_TEMPLATE_DIR" "$remote_host"
|
||||
fi
|
||||
# create the non existing remote BTRFS subvolume
|
||||
@@ -1,9 +1,9 @@
|
||||
###
|
||||
# snapper template for snap-sync handling
|
||||
# snapper template for dsnap-sync handling
|
||||
###
|
||||
|
||||
# subvolume to snapshot
|
||||
SUBVOLUME="/var/lib/snap-sync"
|
||||
SUBVOLUME="/var/lib/dsnap-sync"
|
||||
|
||||
# filesystem type
|
||||
FSTYPE="btrfs"
|
||||
@@ -1,11 +1,11 @@
|
||||
#!/bin/bash
|
||||
#!/bin/sh
|
||||
|
||||
etcdirs="sysconfig default conf.d"
|
||||
|
||||
for x in $etcdirs; do
|
||||
d=/etc/$x/snapper
|
||||
if [[ -f $d ]]; then
|
||||
sed -i 's@^SNAPPER_CONFIG=.*@SNAPPER_CONFIG='$d'@g' bin/snap-sync
|
||||
if [ -f $d ]; then
|
||||
sed -i 's@^SNAPPER_CONFIG=.*@SNAPPER_CONFIG='$d'@g' bin/dsnap-sync
|
||||
exit 0
|
||||
fi
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user