Daily Backups for Your Puppy
Posted: Thu 16 Mar 2017, 04:07
Edit, 2017-08-28:
You'll find a pet archive of the latest version here.
~~~~~~~~~~~~~
Hello all.
As per Flash's suggestion here, I'm opening this thread about daily
backups, aka dailies.
It saw the light of day as an answer to a question by member scientist.
Then I realized that we had nothing like it, and that it is quite a good idea
finally to save the daily bits of your computing every day. And I continued
adding features to it.
Of course, this kind of backup doesn't move mountains, but that's the
idea: to be almost unnoticeable, automatic, and efficient.
If on a particular day, something in your system breaks, you unpack your
latest dailies, copy their contents in your system and you're back in
business in no time.
We have to thank Barry Kauler for his foresight. I'm just making use of the
start / stop feature he designed for Puppys's /etc/init.d directory.
~~~~~~~~
Please note that you still must do, IMO, regular back-ups, by compacting
your pupsave file as a lzop file with SFR's PackIT, every second day, for
example; or whatever means you usually use. "When things go wrong, you
never have enough back-ups." (Old French-Canadian saying.)
Anyway, you can read the genesis, etc., in the other thread. I'm not sure I
mentioned it elsewhere, but this script uses good old zip and the much
newer lzip. The script needs both. And you will too if you ever need to
access the contents!
So... here's the message transfer!
Enjoy ! BFN.
~~~~~~~~~~~~~~~
Hello all.
Time flies, doesn't it?
This is version 3d. It contains a number of improvements, you be the judge.
For one, I changed the licence to GPL3.
An interesting one, I think is a line added to the time tag at line 87 of the
script, to mention which pupsave this daily is for.
It can help dissipate the confusion if you use 2 or 3 pupsaves with the
same Puppy.
The name of the archive is derived from the name of the Pup, contains the
date, and the numbering of the archive (if you make more than one
computer session during the day).
File /root/Daily_zip.note inside the archive now also contains which pupsave
this daily was made for.
IHTH.
You'll find a pet archive of the latest version here.
~~~~~~~~~~~~~
Hello all.
As per Flash's suggestion here, I'm opening this thread about daily
backups, aka dailies.
It saw the light of day as an answer to a question by member scientist.
Then I realized that we had nothing like it, and that it is quite a good idea
finally to save the daily bits of your computing every day. And I continued
adding features to it.
Of course, this kind of backup doesn't move mountains, but that's the
idea: to be almost unnoticeable, automatic, and efficient.
If on a particular day, something in your system breaks, you unpack your
latest dailies, copy their contents in your system and you're back in
business in no time.
We have to thank Barry Kauler for his foresight. I'm just making use of the
start / stop feature he designed for Puppys's /etc/init.d directory.
~~~~~~~~
Please note that you still must do, IMO, regular back-ups, by compacting
your pupsave file as a lzop file with SFR's PackIT, every second day, for
example; or whatever means you usually use. "When things go wrong, you
never have enough back-ups." (Old French-Canadian saying.)
Anyway, you can read the genesis, etc., in the other thread. I'm not sure I
mentioned it elsewhere, but this script uses good old zip and the much
newer lzip. The script needs both. And you will too if you ever need to
access the contents!
So... here's the message transfer!
Enjoy ! BFN.
~~~~~~~~~~~~~~~
Hello all.
Time flies, doesn't it?
This is version 3d. It contains a number of improvements, you be the judge.
For one, I changed the licence to GPL3.
An interesting one, I think is a line added to the time tag at line 87 of the
script, to mention which pupsave this daily is for.
It can help dissipate the confusion if you use 2 or 3 pupsaves with the
same Puppy.
The name of the archive is derived from the name of the Pup, contains the
date, and the numbering of the archive (if you make more than one
computer session during the day).
File /root/Daily_zip.note inside the archive now also contains which pupsave
this daily was made for.
IHTH.
Code: Select all
#!/bin/sh
# /etc/init.d/stop_today-files3d # A daily archiving script.
# Requires zip and lzip (both are usually in modern puppies).
#
# This is a twin script of today-files3c.sh, without the checking /
# display part at the end. This script uses instead the test of
# the archive provided by zip itself.
#
# To use: copy this script as < stop_today-files3d > in /etc/init.d/
# and make executable.
#
# You may change the receiving PARTition at line 21 below
# to suit your system.
#
# Comments, usage notes, checking/display section and choice of receiving
# partition in script < today-files3c.sh > (q.v.) removed for brevity.
#
# (c) Christian L'Écuyer (aka musher0), July 12, 2015.
# Rev.: April 20 & 24-25, May 8 and Aug. 18, 2016, March 15, 2017.
# All rights reserved / Tous droits réservés. GPL3
####
# variables
PuP="`awk -F"'" '$1 ~ /_NAME/ { print $2 }' /etc/DISTRO_SPECS`" # 18 août 2016
PART="home" # Or define your own.
cd /mnt/"${PART}"
# Added 2016-04-20:
DaT="`date '+%Y-%m-%d'`"
# It is now possible to have an unlimited number of archive files.
count="`ls -1 "${PuP}"-"${DaT}"-files*lz | wc -l`"
count="`expr $count + 1`"
FileS="files${count}"
# Useful if you do many sessions on the same day.
#
# Downside: does not create a timed update, grabs all dailies every time,
# because lzip does not have an update command. Also, on the practical level,
# decompressing the lzip file and unzipping and updating the zip archive will
# lenghten the shutdown cycle, which we want to keep as brief as possible.
# You may wish to keep only the highest-numbered archive of the day
# upon later review.
#
# Upside: this limitation may be useful to do some versioning.
# End of edit.
# functions
mklzip () {
lzip -9m64 -f "${PuP}"-"${DaT}"-"${FileS}".zip
}
# unlzip (){
# cd /mnt/"${PART}"
# lzip -d -k "${DaT}"-"${FileS}".zip.lz
# } # Example of how to decompress an lzip file. # Added 2016-04-20.
# Action
# Exception: Skip the "dailies" archiving for the date
# on which an ?drv_*.sfs was created. This is rather for
# developers. The regular user won't need this. But it's
# not an annoyance for anyone. # Added 2016-04-24 & 25.
ModE="`awk -F"=" '/PUPMODE/ { print $2}' /etc/rc.d/PUPSTATE`"
if [ "$ModE" = "12" -o "$ModE" = "13" ];then # Limits
composante=""
> /tmp/liste.drv
for composante in ADRV= FDRV= YDRV= ZDRV=
do
DrV="`awk -F"'" '$1 ~ /'$composante'/ { print $2 }' /etc/rc.d/PUPSTATE | awk -F"," '{ print $NF }'`"
DrV="/mnt/home$DrV"
[ "${#DrV}" -gt "9" ] && echo "$DrV" >> /tmp/liste.drv
done
cat /tmp/liste.drv
> /tmp/liste.drv1
for i in `cat /tmp/liste.drv`
do
ls --time-style="+%Y-%m-%d" -Algo $i >> /tmp/liste.drv1
done
Nombre="`awk '/'"$DaT"'/ { print $NF }' /tmp/liste.drv1 | wc -l`"
if [ "$Nombre" -gt "0" ];then
for Fichier in `awk '$4 ~ /'"$DaT"'/ { print $NF }' /tmp/liste.drv1`
do
cp -f --backup "$Fichier" "$Fichier".cdr
done # Si on a installé le jour même, on fait une copie de réserve.
else # Sinon, on fait la sauvegarde quotidienne ordinaire.
echo "Daily zip archive / Archive zip quotidienne
For: / Pour : `grep PUPSAVE /etc/rc.d/PUPSTATE`
$DaT, # / n. $count." > /root/Daily_zip.note # Added 2016-04-20, 2017-03-15.
zip -lf /mnt/"${PART}"/zip.log -la -0 -r -y -FI -t "${DaT}" /mnt/"${PART}"/"${PuP}"-"${DaT}"-"${FileS}" /initrd/pup_rw
# /bin /etc /lib /opt /sbin /root /usr /var
# -x /tmp /dev /sys /initrd /mnt # pas nécessaire
# 2016-04-20: Added < -FI > parameter to include FIFO files.
if [ ! -d /initrd/pup_rw/root/my-* ];then
zip -lf /mnt/"${PART}"/zip.log -la -0 -r -u -t "${DaT}" /mnt/"${PART}"/"${PuP}"-"${DaT}"-"${FileS}" /root/my-*
# 2016-05-09
fi
touch /mnt/"${PART}"/"${PuP}"-"${DaT}"-"${FileS}".zip
# 2016-05-08 # Essai de correction de l'erreur de date.
rm -f /root/Daily_zip.note
mklzip
fi
fi
## 30 ##