commit 278364de8d5a28d49d3c585f1734c172be5885fc
parent 9b2cbdbea0e6c673c762d98fbf60bc28277f4e04
Author: vaplv <vaplv@posteo.net>
Date: Sat, 14 Dec 2024 15:39:43 +0100
backup: add backup date to levels 0 filename
So, levels 0 are no longer overwritten. This is an easy way to keep
track of backup history. The administrator must take care of
archiving/deleting them in relation to his backup policy, as disk space
increases drastically with each new level 0.
Diffstat:
| M | backup | | | 13 | +++++++++++-- |
| M | backup.8 | | | 33 | ++++++++++++++++++++++++++++----- |
2 files changed, 39 insertions(+), 7 deletions(-)
diff --git a/backup b/backup
@@ -58,13 +58,22 @@ if ! echo "${lvl}" | grep -qe "^[0-9]" \
seq=0
fi
+suffix=""
+
+# Define the suffix of level 0 backup files by the date on which it is
+# issued. In this way, each level 0 does not overwrite a previous level
+# 0. So, the administrator can archive level 0s according to his or her
+# backup strategy. It's a simple, elegant way of keeping a backup
+# history.
+if [ "${lvl}" -eq 0 ]; then
+ suffix="_$(date +"%Y%m%d%H%M")"
+
# Define the suffix for level 1 backup files; this is the only level
# that will have several files during a complete backup cycle. Sequence
# 0 has no level 1, since it starts with a full backup (i.e. level 0).
# In sequence 1, the backup file is suffixed with 'a', while in sequence
# 2, it is suffixed with 'b'.
-suffix=""
-if [ "${lvl}" -eq 1 ]; then
+elif [ "${lvl}" -eq 1 ]; then
case "${seq}" in
1) suffix="a" ;;
2) suffix="b" ;;
diff --git a/backup.8 b/backup.8
@@ -12,24 +12,24 @@
.\"
.\" You should have received a copy of the GNU General Public License
.\" along with this program. If not, see <http://www.gnu.org/licenses/>.
-.Dd October 1, 2023
+.Dd December 1, 2023
.Dt BACKUP 8
.Os
.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
.Sh NAME
.Nm backup
-.Nd filesystem backup
+.Nd file system backup
.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
.Sh SYNOPSIS
.Nm
.Ar backup_dir
-.Ar files_to_backup ...
+.Ar files_to_backup
.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
.Sh DESCRIPTION
.Nm
-saves the files listed in the
+saves the file system or mount point referenced by the
.Ar files_to_backup
-arguments to the
+argument to the
.Ar backup_dir
directory.
It is a shell script that relies on the
@@ -53,6 +53,29 @@ The dump levels of a complete backup cycle are as follows:
1b -> 3 -> 2 -> 5 -> 4 -> 7 -> 6 -> 9 -> 8 -> 0
.Ed
.Pp
+The name of the file in which a backup is stored begins with
+.Qq backup
+followed by the corresponding level number.
+Level 0 adds an underscore
+.Sq _
+followed by the backup date in ISO 8601 format.
+This prevents a
+previous level 0 from being overwritten.
+It is a simple way of keeping track of backup history.
+It is left to the administrator to archive level 0 backups according to
+his or her policy.
+Finally, all files end with the
+.Qq .dump
+extension.
+.Pp
+A text file corresponding to each backup is also generated to store
+backup information, such as backup dates and backup files.
+These files adopt the same naming convention as the backup files, except
+that the extension is
+.Qq .txt
+instead of
+.Qq .dump .
+.Pp
To keep track of the status of the backup cycle, the identifiers
of the next backup file are stored in the file defined by the
.Ev NEXTBACKUP