From owner-freebsd-questions@freebsd.org Sun Apr 12 21:09:55 2020 Return-Path: Delivered-To: freebsd-questions@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BB5412A99CA for ; Sun, 12 Apr 2020 21:09:55 +0000 (UTC) (envelope-from dpchrist@holgerdanske.com) Received: from holgerdanske.com (holgerdanske.com [IPv6:2001:470:0:19b::b869:801b]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "xray.he.net", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 490ksZ61mYz4g5S for ; Sun, 12 Apr 2020 21:09:54 +0000 (UTC) (envelope-from dpchrist@holgerdanske.com) Received: from 99.100.19.101 ([99.100.19.101]) by holgerdanske.com with ESMTPSA (ECDHE-RSA-AES128-GCM-SHA256:TLSv1.2:Kx=ECDH:Au=RSA:Enc=AESGCM(128):Mac=AEAD) (SMTP-AUTH username dpchrist@holgerdanske.com, mechanism PLAIN) for ; Sun, 12 Apr 2020 14:09:52 -0700 Subject: Re: Restoring and snapshots To: freebsd-questions@freebsd.org References: <56b4e678-0e66-e65b-b9d2-a2e79a5b7b6f@netfence.it> <2a0ee11a-eb32-7ae2-256f-ad1b00d1e49d@netfence.it> From: David Christensen Message-ID: Date: Sun, 12 Apr 2020 14:09:51 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 490ksZ61mYz4g5S X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=none (mx1.freebsd.org: domain of dpchrist@holgerdanske.com has no SPF policy when checking 2001:470:0:19b::b869:801b) smtp.mailfrom=dpchrist@holgerdanske.com X-Spamd-Result: default: False [-2.82 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-0.997,0]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; IP_SCORE(-1.72)[ip: (-0.30), ipnet: 2001:470::/32(-4.66), asn: 6939(-3.60), country: US(-0.05)]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-questions@freebsd.org]; TO_DN_NONE(0.00)[]; AUTH_NA(1.00)[]; RCPT_COUNT_ONE(0.00)[1]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; DMARC_NA(0.00)[holgerdanske.com]; R_SPF_NA(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:6939, ipnet:2001:470::/32, country:US]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2] X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Apr 2020 21:09:55 -0000 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: /etc /usr > /usr/local /var > > I'll snapshot them and back up /etc/.zfs/snapshot/snapname/ > /usr/.zfs/snapshot/snapname/ /usr/local/.zfs/snapshot/snapname/ > /var/.zfs/snapshot/snapname/ > > 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 tree? > > 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? On 2020-04-11 01:31, Andrea Venturoli wrote: > I'm wondering if I should abandon sh and use something else > (Python?). On 2020-04-12 01:50, Andrea Venturoli wrote: > On 2020-04-12 10:23, David Christensen wrote: >> It sounds like you are using file- and directory-level backup tools >> for ZFS filesystems (?). > Exactly. As I said, however, I'm having the same problem with UFS... > You are focusing on ZFS, but this was not the point of the original > post; it was just an example. >> If you are using file- and directory-level backup tools to back up >> ZFS snapshots, that definitely sounds like you are barking up the >> wrong tree. > Sometimes you have complex system, with several machines (some with > ZFS, some with UFS, some with a mix and some not even BSD) and you > need an integrated solution. Handling ZFS filesystem differently from > the others would be a pain. Besides, restoring a whole filesystem if > you just need a couple of files would be very inefficient. I do not use Bacula and have only a basic understanding of it. Beware that "integrated solution" can mean "all your eggs in one basket". That said, two ideas come to mind: 1. It appears Bacula provides a plug-in API. So, write a plug-in for Bacula that knows how to convert Bacula backup saved paths to client filesystem live paths (and vice-versa?) when the former are ZFS snapshots. 2. Have Bacula restore a set of related ZFS snapshots into a temporary directory and then write a script that reassembles everything. A key parameter in any case will be the ZFS 'mountpoint' property for the ZFS snapshots in question. I don't know if Bacula preserves ZFS properties on backup or restore. If not, this information must come from somewhere else. David