Restoring and snapshots
dpchrist at holgerdanske.com
Fri Apr 10 23:53:43 UTC 2020
On 2020-04-10 02:30, Andrea Venturoli wrote:
> When I'm doing backups/dumps of ZFS filesystems (with whatever tool), I
> use snapshots.
> So, suppose I have the following datasets:
> I'll snapshot them and back up
> Then I'll get the same directory structure when restoring.
> Any idea how to easily remove the .zfs/snap and go back to the original
ZFS can roll back a filesystem per a snapshot. See zfs(8) 'rollback'.
Make sure you understand the warnings about destroyed data and about
recursive child snapshots. You will want to disable all services that
use the filesystem(s) while you rollback. Better yet, unmount the
filesystem(s) while you rollback. Whichever snapshot(s) you rollback
to, they will remain after the rollback.
If you want to restore only parts of a filesystem, I believe you must
use filesystem-level tools.
Consider implementing zfs-auto-snapshot.
The ZFS analog of dump(8) is 'zfs send' and the ZFS analog of restore(8)
is 'zfs receive', but there are differences. While you can put storage
device(s) between the two commands and support one ZFS pool over time, I
have a "live" server and pool, a "standby" server and pool, and several
"external disk" pools. I put the 'send' and 'receive' commands into a
pipeline and "replicate" from the "live" pool to the other pools
> I tried writing a few lines of script, but I found out that's not so
> easy (due to directories which must overlap, spaces in file names, etc...).
> Any hint?
> bye & Thanks
I am not sure I understand what you mean by "directories which must
The numerous shells and languages each have their own idiosyncrasies
when it comes to spaces in file and directory names.
For example, suppose I want to view the contents of a text file in a
directory whose name contains spaces. If I use Bash and command
completion, this works:
$ cat path\ with\ spaces/hello.txt
Using Bash by hand, these also work -- note the placement of single quotes:
$ cat 'path with spaces'/hello.txt
$ cat 'path with spaces/hello.txt'
But, this breaks:
$ cat path with spaces/hello.txt
cat: path: No such file or directory
cat: with: No such file or directory
cat: spaces/hello.txt: No such file or directory
Translating the above into a Bourne shell script (which also works under
Bash) -- note the placement of single and double quotes:
$ cat ./foo.sh
dir='path with spaces'
The key concept is that each path component needs to be preserved as a
single unit, and not broken into pieces if it contains spaces.
More information about the freebsd-questions