:: Re: [DNG] Backup methods for Devuan
Página superior
Eliminar este mensaje
Responder a este mensaje
Autor: Steve Litt
Fecha:  
A: dng
Asunto: Re: [DNG] Backup methods for Devuan
nisp1953 via Dng said on Sat, 25 May 2024 12:07:55 -0600

>Hello:
>
> I recently installed Devuan Daedalus 5.0 and it is working great.
>Thanks very much. I need advice on ways to backup my /home user
>account. I have been using tar but I am hoping the list can advise me
>of a better backup method or Debian (Devuan) package that I can use.
>I'd prefer something that does incremental backups.


From what I understand, you want backups and incremental backups. The
following code does what you want. I'll explain it below the code:


========================= begin allbup ==========================

#!/bin/bash

usage(){
echo ""
echo "ERROR: No dir /mnt/backup_local/stevebup/latest/meta"
echo "allbup should be run only if a USB drive mounted to
/mnt/backup_local"
echo "and that drive contains directory /stevebup/latest/meta
directory."
echo "Aborting with exit 11."
echo ""
exit 11
}

[ -d /mnt/backup_local/stevebup/latest/meta ] || usage
cd /d/bats/backup_local
./metabup
./abup
./lbup
./cabup
./ibup
./sysbupbup
./dbup
./sbup
./pbup
./dadbup
./imapbup
./slittbup
./make_incremental.sh
========================= end allbup ==========================

================== begin make_incremental.sh ==================
#!/bin/bash
[ -d /mnt/backup_local/stevebup/latest/meta ] || exit 11
datestamp=`head -n1
/mnt/backup_local/stevebup/latest/meta/timestamp.txt`
incname=inc_$datestamp

cd  /mnt/backup_local/stevebup
echo "PLEASE WAIT, MAKING INCREMENTAL COPY, cp -al latest $incname..."
time cp -al latest  $incname
echo "DONE WITH    MAKING INCREMENTAL COPY, cp -al latest $incname..."


echo "PLEASE WAIT, SYNCING"
time sync
echo "DONE WITH    SYNCING, UNMOUNT NOW"
================== end make_incremental.sh ==================


===================== begin slittbup =====================
#!/bin/bash
[ -d /mnt/backup_local/stevebup/latest/meta ] || exit 11
RSYNC_RSH="ssh -c arcfour -o Compression=no -x"
rsync -vaxHA --progress --numeric-ids --delete  \
    --exclude-from=slittbup_backup.excludes  --delete-excluded \
    /home/slitt /mnt/backup_local/stevebup/latest
===================== end slittbup =====================


NOTE: You might want to remove the "x" from "-vaxHA so that on backups
an immutable file can be replaced. Advantages and disadvantages each
way.

Here's the deal: This series of shellscripts copies changed files to
the "latest" directort on a USB3 hard disk, and then hard-link all the
files to a dated directory so forever more that dated directory
represents what you had on your computer the day you backed it up.
Because you copy only changed files, after your first backup, later
backups happen very fast. The slowest thing is the cp -al in
make_incremental.sh. Perhaps you can accomplish the same thing in
less time using rsync's --link-dest.

Details: The allbup script makes sure your destination has directory
/mnt/backup_local/stevebup/latest/meta to minimize the chance of your
writing over the wrong directory. Obviously you need to put that
directory on every backup drive you use. allbup then calls scripts for
each directory you want to back up (only home, corresponding to my
slittbup in your case), and then calling make_incremental.sh to create
your incremental backup, and notice that your incremental backup is
dated and contains *all* files, so you don't need to restore a full
backup and then one by one restore backups (ugh!).

The slittbup script once again checks for the magic directory, and if
it exists, rsyncs the desired stuff to the "latest" directory, which
already has all files from the preceding backup, so only changed files
go over the wire.

A few more things: I recommend you unplug the backup drive as soon as
the backup has been fully done including incremental, so that if a
badguy hacks your computer or encrypt-kidnaps it, he can't get to your
backup disk. I also recommend multiple backup disks. At a minimum, one
at a moment's reach and one in a bank safety deposit box high off the
ground to prevent flood damage. Perhaps a third inside a metal garbage
can to lessen harm from EMP. If you have a trusted friend, trusted in
both ethics and competency, you can also ship one to him/her once a
year in case a hurricane, fire or earthquake wipes out both your house
and the nearby bank.

A pro move would be to also format your backup LUKS, with a password
you can remember forever, to limit the damage if it falls into the
wrong hands. Keep in mind though that with the advent of quantum
computing, all our current encryption methods will be easily brute
forced in a few years.

I've used this method for about 15 years, on Mandriva, Ubuntu, Debian
and Void, and its proven easy to back up and reliable to restore.

One more thing: In your case, with only 34GB of /home, the hot tip
might be to do the backup as root and back up the entire filesystem
from / on down, for easier restorability. In this case, don't use
-vaxHA, use -vaHA, because you don't want immutable files messing up
incremental backups --- you'd much prefer to remember the extended
attributes and re-apply them on restore. LOL, about the only extended
attribute I use is chattr -i /etc/resolv.conf to prevent the
poetterists from messing with it. Prior to backing up, you could also
apply a shellscript to find all files with extended attributes and back
up that file.

HTH,

SteveT

Steve Litt

Autumn 2023 featured book: Rapid Learning for the 21st Century
http://www.troubleshooters.com/rl21