Skip to content

Commit d0634b5

Browse files
authored
Merge pull request #44 from plattfot/10/deprecate_config_option
Deprecate `--config` and add explicit `SOURCE`/`DEST` interface
2 parents c558a9d + 1e3e0a8 commit d0634b5

10 files changed

Lines changed: 849 additions & 295 deletions
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
### Deprecated
2+
- `--config` and `--type` options.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
### Added
2+
- Interface to specify `SOURCE` and `DEST` explicitly.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
### Added
2+
- `--source SOURCE` option, to override `SOURCE=` in configfile.
3+
- `--dest DEST` option, to override `DEST=` in configfile.
4+
- `SOURCE=` configfile option.
5+
- `DEST=` configfile option.
6+
- `--src-private-key` to set the ssh private key for `SOURCE`.
7+
- `--dest-private-key` to set the ssh private key for `DEST`.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
### Changed
2+
- `--private-key` now also sets ssh private key for `SOURCE` and `DEST`.

‎README.md‎

Lines changed: 92 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -70,19 +70,53 @@ release.
7070
- [ ] Run as none root user.
7171

7272
## Usage
73+
First set up snapper to take snapshots of one of your subvolumes, see this [page](https://wiki.archlinux.org/index.php/Snapper) on how to do it for Arch Linux.
7374

74-
First set up snapper to take snapshots of one of your subvolumes, see
75-
this [page](https://wiki.archlinux.org/index.php/Snapper) on how to do
76-
it for Arch Linux.
75+
### Specify source and destination
7776

78-
For example if you want to back up you snapshots from your home
79-
subvolumes to an external hdd mounted at /mnt/backup, run
77+
If you want to back up your snapper snapshots for your home configuration, where the snapshots located in `/home/.snapshots`, to an external hdd mounted at `/mmt/backup`.
78+
79+
```bash
80+
$ baksnapper /home/.snapshots /mnt/backup/home
81+
```
82+
83+
This will send the last snapshot of home to `/mnt/backup/home/<snapshot nr>'.
84+
85+
To backup all snapshots run:
86+
```bash
87+
$ baksnapper /home/.snapshots --all /mnt/backup/home
88+
```
89+
90+
This will mirror what is in `/home/.snapshots` to `/mnt/backup/home`.
91+
92+
To remove backups that snapper has discarded add the flag -p/--prune:
93+
```bash
94+
$ baksnapper /home/.snapshots --all --prune /mnt/backup/home
95+
```
96+
97+
To delete specific backups from the backup directory, run:
98+
```bash
99+
$ baksnapper /home/.snapshots /mnt/backup/home --delete 1,2,3,63
100+
```
101+
102+
This will only delete 1,2,3 and 63 if they only contain a info.xml
103+
file and a snapshot dir. Otherwise it will issue a warning and skip
104+
the directory.
105+
106+
For help use the `-h`/`--help` flag
107+
```bash
108+
$ baksnapper --help
109+
```
110+
### Snapper config interface (deprecated)
111+
112+
For example if you want to back up your snapshots from your home
113+
snapshots to an external hdd mounted at /mnt/backup, run
80114

81115
```bash
82116
$ baksnapper -c home /mnt/backup
83117
```
84118

85-
This will send the last snapshots of home to
119+
This will send the last snapshot of home to
86120
/mnt/backup/home/<snapshot nr>
87121

88122
To backup all snapshots run:
@@ -110,10 +144,10 @@ For help use the -h/--help flag
110144
```bash
111145
$ baksnapper --help
112146
```
113-
## Remote backup over ssh
147+
### Remote backup over ssh
114148

115149
In order to be able to backup to a remote location you first need to
116-
install baksnapper on the remote machine, or atleast copy over the
150+
install baksnapper on the remote machine, or at least copy over the
117151
baksnapperd script.
118152

119153
Next up is to create a ssh key that baksnapper can use to access the
@@ -153,25 +187,62 @@ It should print out "Connection works".
153187

154188
If everything is working you can now use remote backup with
155189
baksnapper. It uses the same syntax as scp,
156-
i.e. <address>:<path>. For example backup to machine named foo:
190+
i.e. <address>:<path>. For example backup to machine named foo.example.com:
157191

158192
```bash
159-
$ baksnapper --config home --all foo:/mnt/backup
193+
$ baksnapper /home/.snapshots --all foo.example.com:/mnt/backup/home
194+
```
195+
196+
And for the deprecated snapper config interface:
197+
198+
```bash
199+
$ baksnapper --config home --all foo.example.com:/mnt/backup
160200
```
161201

162202
**Tip:** If your are using a nonstandard ssh port you can specify it
163203
in the .ssh/config, for example
164204
```bash
165-
Host foo
205+
Host foo.example.com
166206
Port 666
167207
```
168208

169209
**Tip:** If you have multiple keys, you can specify what key
170-
baksnapper should use either with the option
210+
baksnapper should use either with the option:
211+
212+
```bash
213+
$ baksnapper /home/.snapshots --all foo.example.com:/mnt/backup/home --dest-private-key /root/.ssh/<BAKSNAPPERD-PRIVATE-KEY>
214+
```
215+
216+
And for the deprecated snapper config interface:
217+
```bash
218+
$ baksnapper --config home --all foo.example.com:/mnt/backup --private-key /root/.ssh/<BAKSNAPPERD-PRIVATE-KEY>
219+
```
220+
221+
Or specify that in the Config file using `DEST_PRIVATE_KEY` or `PRIVATE_KEY` for the deprecated snapper config interface.
222+
223+
#### Backup from a remote machine over ssh
224+
225+
You can also pull snapshots from a remote machine to a local location using
226+
227+
```bash
228+
$ baksnapper foo.example.com:/home/.snapshots /mnt/backup/home
229+
```
230+
231+
And you can specify the private key using `--src-private-key` similar to what you do with `--dest-private-key`.
232+
233+
The deprecated snapper config interface you can do the same but it is not as intuitive:
234+
235+
```bash
236+
$ baksnapper --config home foo.example.com:/mnt/backup --type=pull
237+
```
238+
239+
Note that `/mnt/backup` is on the local machine, and `--config home` is for `foo.example.com` — There is a reason why this interface is deprecated.
240+
241+
There is also possible to pull backups from one remote machine and send them to another remote machine:
242+
171243
```bash
172-
$ baksnapper config home --all foo:/mnt/backup --private-key /root/.ssh/<BAKSNAPPERD-PRIVATE-KEY>
244+
$ baksnapper foo.example.com:/home/.snapshots bar.example.com:/mnt/backup/home
173245
```
174-
Or specify that in the Config file using PRIVATE_KEY.
175246

176247
## Config file
177248

@@ -188,26 +259,28 @@ For boolean parameters YES, yes, yes and 1 are interpret as on/true and
188259
anything else as off/false.
189260

190261
The supported options are:
191-
* CONFIG: The snapper config to backup. Same as --config.
192-
* PATH: Destination to backup to. For remote backup use
262+
* CONFIG (deprecated): The snapper config to backup. Same as --config. (deprecated)
263+
* PATH (deprecated): Destination to backup to. For remote backup use
193264
hostname:/backup/to. Where 'hostname' is the name of the
194265
server and '/backup/to' is the path to the location it should
195266
write the backups to on the remote host.
267+
* SOURCE: Source of the snapshots directory to backup. Same as first positional argument and `--source`. For remote backup use `[user@]hostname:/backup/from`. Where `user` is the username — it is optional and if left out till will use the current user. And `hostname` is the name of the server and `/backup/from` is the path to the location where the snapshots are located.
268+
* DEST: Destination for the backup. Same as second positional argument and `--dest`. For remote backup use `[user@]hostname:/backup/to`. Where `user` is the username — it is optional and if left out till will use the current user. And `hostname` is the name of the server and `/backup/to` is the path to the location where it should write the backups to on the remote host.
196269
* PRUNE: Prune the backups by deleting snapshots that isn't in the source directory.
197270
Same as -p, --prune
198271
* ALL: Send all snapshots in the soruce directory. Same as -a, --all
199272
* VERBOSE: Verbose print out, same as -v, --verbose.
200273
* DAEMON: Name of the baksnapper daemon, default is baksnapperd. Same as --daemon
201-
* TYPE: Define if it should push the backup or pull. Default is push.
274+
* TYPE (deprecated): Define if it should push the backup or pull. Default is push.
202275
Pull can be used to transfer a backup from a remote server to
203276
the current machine.
204277
* PRIVATE_KEY: The private key file to use when connecting to a remote
205278
server. Same as --private-key.
206279

207280
**Note:** Command line options will take precendence over config file options.
208281
**Note:** No variable expansion is supported in the config files, for
209-
example you cannot for example type ~/backup, instead you need to
210-
expand ~ yourself i.e /home/bob/backup if $USER = bob.
282+
example you cannot for example type `~/backup`, instead you need to
283+
expand ~ yourself i.e /home/bob/backup if `$USER` expands to `bob`.
211284

212285
## Systemd
213286

0 commit comments

Comments
 (0)