From owner-freebsd-questions@freebsd.org Mon Jan 25 11:05:59 2016 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C6979A45072 for ; Mon, 25 Jan 2016 11:05:59 +0000 (UTC) (envelope-from matthew@freebsd.org) Received: from smtp.infracaninophile.co.uk (smtp.infracaninophile.co.uk [IPv6:2001:8b0:151:1:3cd3:cd67:fafa:3d78]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.infracaninophile.co.uk", Issuer "infracaninophile.co.uk" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 447861F8 for ; Mon, 25 Jan 2016 11:05:59 +0000 (UTC) (envelope-from matthew@freebsd.org) Received: from ox-dell39.ox.adestra.com (no-reverse-dns.metronet-uk.com [85.199.232.226] (may be forged)) (authenticated bits=0) by smtp.infracaninophile.co.uk (8.15.2/8.15.2) with ESMTPSA id u0PB5cG3023157 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO) for ; Mon, 25 Jan 2016 11:05:48 GMT (envelope-from matthew@freebsd.org) Authentication-Results: smtp.infracaninophile.co.uk; dmarc=none header.from=freebsd.org DKIM-Filter: OpenDKIM Filter v2.10.3 smtp.infracaninophile.co.uk u0PB5cG3023157 Authentication-Results: smtp.infracaninophile.co.uk/u0PB5cG3023157; dkim=none; dkim-atps=neutral X-Authentication-Warning: lucid-nonsense.infracaninophile.co.uk: Host no-reverse-dns.metronet-uk.com [85.199.232.226] (may be forged) claimed to be ox-dell39.ox.adestra.com Subject: Re: rolling backup To: freebsd-questions@freebsd.org References: <56A5F7FF.1050606@gmail.com> From: Matthew Seaman X-Enigmail-Draft-Status: N1110 Message-ID: <56A6017E.4020801@freebsd.org> Date: Mon, 25 Jan 2016 11:05:34 +0000 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 MIME-Version: 1.0 In-Reply-To: <56A5F7FF.1050606@gmail.com> Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="LIRXnxtw2htWN2pPAQHiMSt98lX2J9nWb" X-Virus-Scanned: clamav-milter 0.99 at lucid-nonsense.infracaninophile.co.uk X-Virus-Status: Clean X-Spam-Status: No, score=-2.6 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on lucid-nonsense.infracaninophile.co.uk X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Jan 2016 11:05:59 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --LIRXnxtw2htWN2pPAQHiMSt98lX2J9nWb Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 01/25/16 10:25, Sergei G wrote: > Is there any good application for maintaining a rolling backup of > filesystem? There are several alternatives here, but the standout application for system backups is bacula. However I suspect that this will be way overkill for your purposes -- it's designed to backup whole networks of machines and needs its own RDBMS in order to track backup state. The trouble with backup software is that there is such a wide range of requirements over all the different possible users that once you've written a piece of software that is sufficiently flexible to support just about any common usage (and do and the management of archiving, backup cycling, indexing, restores etc. etc.) you will end up with a behemoth. If you want a small and neat script that does exactly what you want, then your best approach is to write it yourself. > I wrote this simple Makefile that's called from a periodic scripts to > maintain backups. However, over time it will run out of space. The > solution would be to have the same backup reusing file names using a > rolling backup scheme. Is there a project that can do that already? Hmmm.... is there any particular reason to use make(1) here? You don't appear to be utilizing any of the special features of make such as creating an output file dependant on the ages of any input files. It's not that it's wrong to use make(1) like that, but it would be more usual to write that as a shell script. Probably slightly faster too, but I expect the overhead from make(1) is lost in the noise compared to how long it takes to run dump. > In rolling backup I would be using parts of the date output (date -j > +"%Y-%m-%d %H:%M:%S") and a mod operation to roll the number. I just > don't have time to spend on it... Actually, I think your best bet is a small extension to your backup script that just deletes all but the last N copies of the backup for a particular filesystem. Something like: ls -1t $(backupdir)/root_* | sed -e "1,$(N)d" | xargs rm Deleting 'all but the last N' is a good strategy with backups. Suppose for whatever reason, backup fails for N nights in a row. If you just deleted backup files that were over N days old, you'ld be left without any backups at all after a certain time. However, keeping a certain number of files means that you still have some backups available, albeit older than would be ideal. Cheers, Matthew --LIRXnxtw2htWN2pPAQHiMSt98lX2J9nWb Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iQIcBAEBCgAGBQJWpgF+AAoJEABRPxDgqeTn75UP/0/au433V3WjLeD5j1/c9ohu AM18Env3Gp+zWZnDPXb4us3VdI7WBIUCELsA2Nq6jPDBzG86W4sVqlhshhwyF+hJ /TljskU0jF6DaFQpiEhOvyEtYFPGs0WwI0bx954Pb/DPmEbERG8qPbeklpEiWDwe 8Zyz/DS4l76xT8951s1u1u+AXXYnzO4YTGtjqfkQAF6R1Nr0b8v1hs/SKp14k6pI rGDl6FUR9wIagQTP+NdBL5OeD70qaIOfoASRwEY+rn5E/kCkf0cWNDKMQz5IYBCL l42EUTnjahLP8p20vYMbtUXHPlvs6ELHl/KAYGw399QtYlXrt4an8F8C1FIxJ14m K/5WLvPrNms5iMoqilY/U72jGNBvoqQ4jBEf/wed8eFVoCqhAZhW0R6YXDXVb3Eb 9fhOXC2BDJdAKpbFgzy7qqr14qQOgkiYv2wMnqHiqFmdq6Cueh0t+FvoORItcVeL Oh0FCfVtbvZ8qcYaGi6QMVLTfeieo0iUgXtUfRP8k0+6YUjpFNmq6vaQu2gWGN6u jx69nCj0YgdKFVRNR5/xzxEroVOQndhZUAq7SYA3QLNrOasXuA+jJP8gHqwS/Vdt k40eg9vWTDVl1LzBre15RkABl+oeJwK65OUGjU5CKa6VRs3FWunGPARFPjP+ae4B 2666NBHXhdsO2sDwqGu/ =VY/r -----END PGP SIGNATURE----- --LIRXnxtw2htWN2pPAQHiMSt98lX2J9nWb--