From nobody Fri Mar 29 13:08:17 2024
X-Original-To: freebsd-questions@mlmmj.nyi.freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1])
	by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4V5gh66MGGz5GHPK
	for <freebsd-questions@mlmmj.nyi.freebsd.org>; Fri, 29 Mar 2024 13:08:22 +0000 (UTC)
	(envelope-from cryintothebluesky@gmail.com)
Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d])
	(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
	 key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256
	 client-signature RSA-PSS (2048 bits) client-digest SHA256)
	(Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK))
	by mx1.freebsd.org (Postfix) with ESMTPS id 4V5gh621cCz44Kb
	for <freebsd-questions@freebsd.org>; Fri, 29 Mar 2024 13:08:22 +0000 (UTC)
	(envelope-from cryintothebluesky@gmail.com)
Authentication-Results: mx1.freebsd.org;
	dkim=pass header.d=gmail.com header.s=20230601 header.b=c3dQj2wo;
	dmarc=pass (policy=none) header.from=gmail.com;
	spf=pass (mx1.freebsd.org: domain of cryintothebluesky@gmail.com designates 2a00:1450:4864:20::12d as permitted sender) smtp.mailfrom=cryintothebluesky@gmail.com
Received: by mail-lf1-x12d.google.com with SMTP id 2adb3069b0e04-513dc9d6938so2377504e87.2
        for <freebsd-questions@freebsd.org>; Fri, 29 Mar 2024 06:08:22 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20230601; t=1711717698; x=1712322498; darn=freebsd.org;
        h=content-transfer-encoding:mime-version:references:in-reply-to
         :message-id:subject:cc:from:date:from:to:cc:subject:date:message-id
         :reply-to;
        bh=0uhf+jmnojOxwus7Ww68xTJvTCsnI9arYXFKjhfysqY=;
        b=c3dQj2woxksvIOcwryuPoCjXut8hxnCs5m0ll3FYiaUCNgneZZzMl5ct4ip8RdBRpa
         9kmNz5RU3Unhe1ZS2eUXZ57rznZ2ysaB6uoq5GSp/ApwFmuPIAgMrHUTSpKpCtyGN47Y
         Gc5RzgW0rYM0m9P7nQeOCmAI3aifQ7BT/dhi1Z2hnL2k9tj6qaaiqxuw63viC1lV79+t
         QBVYvLpfm9ToJNFp/uZfSdSi0UqyByA7+qgnWoRNECNHe6n66wZekhghD3zJwm1TIvha
         VtNkQCyX7IeX/Il7VbLrZpFHFRfXydvHuSt8DrJcROvge0W0ZIbHPJZE5/yPlLuLoTm9
         8XVw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20230601; t=1711717698; x=1712322498;
        h=content-transfer-encoding:mime-version:references:in-reply-to
         :message-id:subject:cc:from:date:x-gm-message-state:from:to:cc
         :subject:date:message-id:reply-to;
        bh=0uhf+jmnojOxwus7Ww68xTJvTCsnI9arYXFKjhfysqY=;
        b=lPGJjg+BLpp88DC+MWAQO2X7Vy5Bx2cpaKgVMJrsUWOPGiomjCjowiT803qMPpgJ/h
         16HiF7k7qI0Y5yMx1hoDfxRraQzk+hcWncXzDKEitnOQbLSHYKeK5yix+oZx+t8Wf2zK
         zhsvLavEwYOQFBiwQxLFh+Gz2mg+sAkEsc3DuEU7ABwcc+c/fko5+9TSru+dI+Y7sg/P
         9BxQ+MJ4He0Z5E1KQ5VsAquW4x/B/mvV0pbFS0FjrZ7brryDy++4JHO8x1mSwGU9k/Q3
         wVAb6fbpSFPK/MsfGGWTGbBvu3m3LVdgndqM/wagWAFgXz9qQTdvzDPiQAWEaLNhhVPc
         VepA==
X-Gm-Message-State: AOJu0YyEY3nv4L5Z3QSaZ+hv/STT7Zp7k09d6Fehl7b30Wy/iZc3pxg7
	+pd/tWqbi3WYg8knSCmYCFr+62ZgZo8lHq1RY6cpcrKYs2lGyCAtV6O1VYB7
X-Google-Smtp-Source: AGHT+IEdwe4u/+voW8vSGzIq3naeI/aIpPXTdifIjfPTzmvJhmnOXahhBzNTst8OtvvyJneaaA+Rvg==
X-Received: by 2002:a19:e047:0:b0:513:dac5:ee1a with SMTP id g7-20020a19e047000000b00513dac5ee1amr1651779lfj.25.1711717698431;
        Fri, 29 Mar 2024 06:08:18 -0700 (PDT)
Received: from z600.home.lan (157.85.199.146.dyn.plus.net. [146.199.85.157])
        by smtp.gmail.com with ESMTPSA id q17-20020a05600c46d100b0041409db0349sm5379101wmo.48.2024.03.29.06.08.18
        for <freebsd-questions@freebsd.org>
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Fri, 29 Mar 2024 06:08:18 -0700 (PDT)
Date: Fri, 29 Mar 2024 13:08:17 +0000
From: Sad Clouds <cryintothebluesky@gmail.com>
Cc: freebsd-questions@FreeBSD.org
Subject: Re: UFS snapshots and dump/restore
Message-Id: <20240329130817.8bcf89e92dad709c46709e2f@gmail.com>
In-Reply-To: <20240329121541.9b0163bef978b5e5fcfd54a7@gmail.com>
References: <20240329121541.9b0163bef978b5e5fcfd54a7@gmail.com>
X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu)
List-Id: User questions <freebsd-questions.freebsd.org>
List-Archive: https://lists.freebsd.org/archives/freebsd-questions
List-Help: <mailto:questions+help@freebsd.org>
List-Post: <mailto:questions@freebsd.org>
List-Subscribe: <mailto:questions+subscribe@freebsd.org>
List-Unsubscribe: <mailto:questions+unsubscribe@freebsd.org>
Sender: owner-freebsd-questions@freebsd.org
X-BeenThere: freebsd-questions@freebsd.org
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
X-Spamd-Bar: /
X-Spamd-Result: default: False [-0.50 / 15.00];
	MISSING_TO(2.00)[];
	NEURAL_HAM_LONG(-1.00)[-1.000];
	NEURAL_HAM_MEDIUM(-1.00)[-1.000];
	MV_CASE(0.50)[];
	DMARC_POLICY_ALLOW(-0.50)[gmail.com,none];
	R_DKIM_ALLOW(-0.20)[gmail.com:s=20230601];
	R_SPF_ALLOW(-0.20)[+ip6:2a00:1450:4000::/36];
	MIME_GOOD(-0.10)[text/plain];
	NEURAL_SPAM_SHORT(0.00)[0.003];
	RCVD_TLS_LAST(0.00)[];
	TO_MATCH_ENVRCPT_ALL(0.00)[];
	ARC_NA(0.00)[];
	MIME_TRACE(0.00)[0:+];
	RCPT_COUNT_ONE(0.00)[1];
	FREEMAIL_ENVFROM(0.00)[gmail.com];
	FREEMAIL_FROM(0.00)[gmail.com];
	FROM_HAS_DN(0.00)[];
	ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US];
	DWL_DNSWL_NONE(0.00)[gmail.com:dkim];
	TO_DN_NONE(0.00)[];
	RCVD_COUNT_TWO(0.00)[2];
	FROM_EQ_ENVFROM(0.00)[];
	DKIM_TRACE(0.00)[gmail.com:+];
	PREVIOUSLY_DELIVERED(0.00)[freebsd-questions@freebsd.org];
	MID_RHS_MATCH_FROM(0.00)[];
	MLMMJ_DEST(0.00)[freebsd-questions@freebsd.org];
	RCVD_VIA_SMTP_AUTH(0.00)[];
	RCVD_IN_DNSWL_NONE(0.00)[2a00:1450:4864:20::12d:from]
X-Rspamd-Queue-Id: 4V5gh621cCz44Kb

On Fri, 29 Mar 2024 12:15:41 +0000
Sad Clouds <cryintothebluesky@gmail.com> wrote:

> Despite the nodump flag, /data/.snap/latest is still dumped and
> restored. This causes /data/.snap/latest to be reset to 0 bytes after
> running restore and the snapshot is lost. Any idea why such behaviour?

I think I know what's going on - inside the snapshot there is an empty
file with the same snapshot name. This is created before nodump is set.

To make dump/restore work without corrupting the original snapshot, I
had to rename the snapshot after creation.

Create snapshot and rename it:
# snapshot="/data/.snap/latest"
# mksnap_ffs ${snapshot}.tmp && chflags nodump ${snapshot}.tmp
# mv ${snapshot}.tmp ${snapshot}

Restore snapshot with dump then delete empty snapshot file:
# snapshot="/data/.snap/latest"
# cd $(dirname ${snapshot})/../ && dump -0 -a -h 0 -C 16 -b 64 -f - ${snapshot} | restore -xuvf -
# rm -f ${snapshot}.tmp