From owner-freebsd-questions@freebsd.org Sat Apr 11 22:36:52 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 06C4827DA29 for ; Sat, 11 Apr 2020 22:36:52 +0000 (UTC) (envelope-from dpchrist@holgerdanske.com) Received: from holgerdanske.com (holgerdanske.com [184.105.128.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "holgerdanske.com", Issuer "holgerdanske.com" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4908rM02SGz4D9X for ; Sat, 11 Apr 2020 22:36:50 +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 ; Sat, 11 Apr 2020 15:36:45 -0700 Subject: Re: Restoring and snapshots To: freebsd-questions@freebsd.org References: <56b4e678-0e66-e65b-b9d2-a2e79a5b7b6f@netfence.it> From: David Christensen Message-ID: <94571e53-636a-cc92-55ea-e2203194007a@holgerdanske.com> Date: Sat, 11 Apr 2020 15:36:45 -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: 8bit X-Rspamd-Queue-Id: 4908rM02SGz4D9X 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 184.105.128.27) smtp.mailfrom=dpchrist@holgerdanske.com X-Spamd-Result: default: False [-1.68 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; NEURAL_HAM_MEDIUM(-0.96)[-0.965,0]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; IP_SCORE(-0.62)[ipnet: 184.104.0.0/15(0.54), 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)[-0.995,0]; DMARC_NA(0.00)[holgerdanske.com]; RCVD_IN_DNSWL_NONE(0.00)[27.128.105.184.list.dnswl.org : 127.0.10.0]; 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:184.104.0.0/15, 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: Sat, 11 Apr 2020 22:36:52 -0000 On 2020-04-11 15:18, David Christensen wrote: > On 2020-04-11 01:31, Andrea Venturoli wrote: >> On 2020-04-11 01:53, David Christensen wrote: > >> let's suppose I'm restoring data from a ZFS system on a non ZFS >> filesystem. >> I just have plain files and I have to deal with that. > > I am confused: > > *  What is the type of the filesystem that was the source of the backup? > > *  What tool(s) did you use to backup? > > *  What is the type of the filesystem that was the destination of the > backup?  Is the the source of the restore? Correction: Is this the source of the restore? > > *  What tool(s) are you using to restore? > > *  What is the type of the filesystem that is the destination of the > restore? > > >> For example, after restore, > >> I have: >> >> .../usr/jails/.zfs/snapshot/snapname/dc/ >> and >> .../usr/jails/dc/.zfs/snapshot/snapname/ > > So, the backup source filesystem and the restore destination filesystems > are both ZFS (?). > > > What you have show above is the default Unix filesystem representations > of snapshots for two ZFS filesystems: > >     pool/.../jails > >     pool/.../jails/dc > > > The upper Unix filesystem path should be an empty directory. > > > The lower Unix filesystem path should contain the contents of the > pool/.../jails/dc ZFS filesystem (.../usr/jails/dc Unix filesystem) when > the snapshot was taken. > > >> (This is a result of ezjail use of nullfs). > > I believe it is a result of the 'mountpoint' properties of the two ZFS > file systems and how ZFS represents filesystem snapshots in the Unix > file system. > > >> So (in my script) I cannot simply "mv" directories around, but >> sometimes I need to "merge" them. > > AIUI the Unix filesystem namespace, the ZFS filesystem namespace, and > the ZFS snapshot namespace are related by: > > *  ZFS properties -- 'canmount', 'mounted', 'mountpoint', and 'snapdir'. > > *  ZFS design -- notably Unix filesystem representation of ZFS > snapshots: '.zfs/snapshot/filesystem@snapname'. Correction: '.zfs/snapshot/snapname' > *  Filesystem and ZFS operations over time. > > > Navigating these namespaces by hand is tricky.  Writing scripts to > navigate them is non-trivial. > > >> The real problem, when writing my script, is that I end up looping >> over results of `ls ...` or `find ...`. I read that is considered bad >> practice, so I asked if, maybe, there was a better way. >> Up to now, it seems not... > > I believe looping over the results of a command in a Bourne shell script > is a common programming technique.  But, I would probably invoke the > command and store the results into a variable on one line and start a > loop over the variable contents on another line, so that I could insert > a debug echo between the two lines and see the contents of the variable. > > >> I'm wondering if I should abandon sh and use something else (Python?). > > When I migrated from Linux and ext4 to FreeBSD and ZFS, I wanted to > incorporate zfs-auto-snapshot and replication in my disaster recovery > plans.  This required me to rethink my workflows and revise or rewrite > the associated Bourne and Perl scripts.  For simple stuff, I found that > I could write and deploy Bourne scripts more easily and quickly than > Perl scripts.  For non-simple stuff, sometimes I wrote a Bourne script > that called a Perl script for crux moves and sometimes I wrote the whole > script in Perl.  The key differentiators for choosing Perl over Bourne > included command-line option and argument processing, data structures/ > algorithms, and automated testing. > > > David David