1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
|
NAME
byteback-restore - Restore a file to this system from a byteback-enabled server
SYNOPSIS
byteback-restore [ --restore | --list ] [ --snapshot s ]
[ --destination d ] [ --io-timeout i ] [ --ssh-key k ]
[ --list-all ] [ --help ] [ --verbose ] pattern pattern..
OPTIONS
--list, -l List or find files
--restore, -r Restore files
--snapshot, -s s The snaphot to use. (Default: *)
--destination, -d s Backup destination (i.e. user@host:/path). The default is read from /etc/byteback
--io-timeout, -i i Number of seconds to allow I/O timeout for (default: 300)
--ssh-key, -k s SSH key filename (default: /etc/byteback/key)
--all, -a List/restore all versrions of each file
--verbose, -v Show debugging messages.
--help, -h Show a brief usage message.
DESCRIPTION
Firstly the pattern argument. This is expanded relative to the current directory,
if it is not an absolute path, before being globbed. It is best to quote the
pattern to avoid premature shell expansion. Multiple patterns can be supplied.
To list files that could be restored, just give a pattern. The --list flag can
be used for clarity, but it is entirely optional.
To restore files, use the --restore flag. Restores are always done into the
current working directory. See EXAMPLES below.
GLOBBING
The following character are "globbed":
- "*" matches any filename.
- "**" matches directories recursively.
- "?" matches any single character.
- "[set]" matches any set of characters, working in the same way as regular expressions.
- "{a,b}" matches either literal "a" or literal "b"
- "\\" escapes the next metacharacter.
Note that to match "dotfiles", the pattern "{*,.*}" should be used.
The full glob syntax is documented in the Ruby documentation for the Dir#glob
method.
EXAMPLES
To list the latest copies of the files available, just call the command with
no flags.. The --list flag is optional.
# byteback-restore '/home/patch/.bash*'
snapshot modestring size uid gid mtime path
----------------------------------------------------------------------------------------
current -rw------- 47931 1000 1000 2015-11-29 09:26:10 +0000 /home/patch/.bash_history
current -rw-r--r-- 220 1000 1000 2014-03-10 10:13:33 +0000 /home/patch/.bash_logout
current -rw-r--r-- 3638 1000 1000 2015-07-30 16:33:30 +0100 /home/patch/.bashrc
To list all different available versions of a file, use --all.
# byteback-restore --all '/home/patch/.bashrc'
snapshot modestring size uid gid mtime path
----------------------------------------------------------------------------------------------
2015-07-17T15:11+0100 -rw-r--r-- 3637 1000 1000 2014-03-10 10:13:33 +0000 /home/patch/.bashrc
current -rw-r--r-- 3638 1000 1000 2015-07-30 16:33:30 +0100 /home/patch/.bashrc
To list every single copy of a file, use --verbose. Notice that a number of
these entries match on size and mtime.
# byteback-restore --verbose '/home/patch/.bashrc'
ssh -o BatchMode=yes -o ConnectionAttempts=5 -o ConnectTimeout=30 -o ServerAliveInterval=60 -o TCPKeepAlive=yes -x -a -i /etc/byteback/key -l byteback backups.default.cherry.uk0.bigv.io byteback-receive --snapshot * --list --verbose /home/patch/.bashrc
snapshot modestring size uid gid mtime path
----------------------------------------------------------------------------------------------
2015-04-30T11:44+0100 -rw-r--r-- 3637 1000 1000 2014-03-10 10:13:33 +0000 /home/patch/.bashrc
2015-05-05T15:05+0100 -rw-r--r-- 3637 1000 1000 2014-03-10 10:13:33 +0000 /home/patch/.bashrc
2015-07-17T15:11+0100 -rw-r--r-- 3637 1000 1000 2014-03-10 10:13:33 +0000 /home/patch/.bashrc
2015-11-25T11:14+0000 -rw-r--r-- 3638 1000 1000 2015-07-30 16:33:30 +0100 /home/patch/.bashrc
2015-11-26T13:38+0000 -rw-r--r-- 3638 1000 1000 2015-07-30 16:33:30 +0100 /home/patch/.bashrc
2015-11-27T10:48+0000 -rw-r--r-- 3638 1000 1000 2015-07-30 16:33:30 +0100 /home/patch/.bashrc
2015-11-30T15:37+0000 -rw-r--r-- 3638 1000 1000 2015-07-30 16:33:30 +0100 /home/patch/.bashrc
current -rw-r--r-- 3638 1000 1000 2015-07-30 16:33:30 +0100 /home/patch/.bashrc
Restoring is always to the current directory, and into directories named after the snapshots.
This next command restores the last copies of the files shown in the first
listing above into the "current" directory, as they were all from the "current"
snapshot.
# byteback-restore --restore '/home/patch/.bash*'
Restoring:
snapshot modestring size uid gid mtime path
----------------------------------------------------------------------------------------
current -rw------- 47931 1000 1000 2015-11-29 09:26:10 +0000 /home/patch/.bash_history
current -rw-r--r-- 220 1000 1000 2014-03-10 10:13:33 +0000 /home/patch/.bash_logout
current -rw-r--r-- 3638 1000 1000 2015-07-30 16:33:30 +0100 /home/patch/.bashrc
Using find(1), we can see the files restored. Note that the permissions on the
parent directory have been set correctly.
# find current/ -ls
422049 4 drwxr-xr-x 3 root root 4096 Nov 16 16:04 current/
422050 4 drwxr-xr-x 3 root root 4096 Mar 12 2014 current/home
422885 4 drwxr-xr-x 2 patch patch 4096 Nov 29 09:26 current/home/patch
422886 4 -rw-r--r-- 1 patch patch 220 Mar 10 2014 current/home/patch/.bash_logout
422887 4 -rw-r--r-- 1 patch patch 3638 Jul 30 16:33 current/home/patch/.bashrc
To restore the files from a specific snapshot, use the --snapshot flag.
# byteback-restore --restore --snapshot '2015-07-17T15:11+0100' '/home/patch/.bash*'
Restoring:
snapshot modestring size uid gid mtime path
-----------------------------------------------------------------------------------------------------
2015-07-17T15:11+0100 -rw------- 38504 1000 1000 2015-07-17 13:42:17 +0100 /home/patch/.bash_history
2015-07-17T15:11+0100 -rw-r--r-- 220 1000 1000 2014-03-10 10:13:33 +0000 /home/patch/.bash_logout
2015-07-17T15:11+0100 -rw-r--r-- 3637 1000 1000 2014-03-10 10:13:33 +0000 /home/patch/.bashrc
These have been restored into the 2015-07-17T15:11+0100 directory.
# find 2015-07-17T15:11+0100 -type f -ls
422911 4 -rw-r--r-- 1 patch patch 220 Mar 10 2014 2015-07-17T15:11+0100/home/patch/.bash_logout
422913 40 -rw------- 1 patch patch 38504 Jul 17 13:42 2015-07-17T15:11+0100/home/patch/.bash_history
422912 4 -rw-r--r-- 1 patch patch 3637 Mar 10 2014 2015-07-17T15:11+0100/home/patch/.bashrc
Finally, to restore all available copies of the files, use the --all flag.
This will restore all copies shown when --list is used with the --all flag.
# byteback-restore --restore --all '/home/patch/.bashrc'
Restoring:
snapshot modestring size uid gid mtime path
-----------------------------------------------------------------------------------------------------
2015-07-17T15:11+0100 -rw-r--r-- 3637 1000 1000 2014-03-10 10:13:33 +0000 /home/patch/.bashrc
current -rw-r--r-- 3638 1000 1000 2015-07-30 16:33:30 +0100 /home/patch/.bashrc
We now have two versions of the same file, in different restore directories.
# find -type f -ls
946020 4 -rw-r--r-- 1 patch patch 3637 Mar 10 2014 ./2015-07-17T15:11+0100/home/patch/.bashrc
422893 4 -rw-r--r-- 1 patch patch 3638 Jul 30 16:33 ./current/home/patch/.bashrc
CAVEATS
If a pattern given matches a directory, then the whole directory will be
restored recursively, not just the directory itself. This can be shown by
adding the --verbose flag.
# byteback-restore --verbose --restore '/home/patch'
rsync --archive --numeric-ids --inplace --relative --compress --timeout 300 --rsh ssh -o BatchMode=yes -x -a -i /etc/byteback/key -l byteback --verbose --rsync-path byteback-restore --fake-super --snapshot * byteback@backups.default.cherry.uk0.bigv.io:/home/patch .
Restoring:
snapshot modestring size uid gid mtime path
-------------------------------------------------------------------------
current drwxr-xr-x 5152 1000 1000 2015-11-29 09:26:22 +0000 /home/patch
rsync --fake-super --server --sender -vlogDtprRze.iLsfx --timeout=300 --numeric-ids --inplace --exclude=. . ./current/home/patch
receiving incremental file list
current/home/patch/
current/home/patch/.mrconfig
current/home/patch/.pam_environment
current/home/patch/.plan
current/home/patch/.profile
current/home/patch/.psql_history
etc...
SEE ALSO
byteback-receive(1), byteback-prune(1), http://ruby-doc.org/core/Dir.html#method-c-glob
AUTHOR
Patrick J Cherry <patrick@bytemark.co.uk>
|