Files
bpfire/config/rsnapshot/backup_sqlite.sh
Jon Murphy f23508b724 rsnapshot: New addon
- What is it?
	rsnapshot is a filesystem snapshot utility based on
	rsync. rsnapshot makes it easy to make periodic snapshots of the
	ipfire device. The code makes extensive use of hard links whenever
	possible, to greatly reduce the disk space required.  See:
	https://rsnapshot.org

- Why is it needed?
	Rsnapshot backups run multiple times per day
	(e.g., once per day up to 24 times per day). Rsnapshot is much easier
	to configure, setup and use than the borg backup add-on.  (I found
	borg somewhat confusing). Rsnapshot completes each backup very fast.
	Unlike borg, rsnapshot does not compress each backup before storage.
	During a complete rebuild, borg backup need installation of the borg
	add-on to recover archived files.  Rsnapshot backups can be copied
	directly from the backup drive. Current backups (backup.pl or borg)
	could corrupt sqlite3 databases by running a backup during a database
	write.  This add-on includes a script specifically for sqlite backups.

- IPFire Wiki
	In process at: https://wiki.ipfire.org/addons/rsnapshot

Thanks to Gerd for creating a first build and a nice template for me!

Signed-off-by: Jon Murphy <jon.murphy@ipfire.org>
2023-05-18 11:24:29 +00:00

41 lines
1.3 KiB
Bash

#!/bin/bash
set -e
set -u
#set -x
##############################################################################
# backup_sqlite.sh
#
# http://www.rsnapshot.org/
#
# This is a simple shell script to backup a sqlite database with rsnapshot.
#
# This script simply needs to dump a file into the current working directory.
# rsnapshot handles everything else.
#
# The assumption is that this will be invoked from rsnapshot.
# See:
# https://rsnapshot.org/rsnapshot/docs/docbook/rest.html#backup-script
#
# Please remember that these backup scripts will be invoked as the user
# running rsnapshot. Make sure your backup scripts are owned by root,
# and not writable by anyone else.
# If you fail to do this, anyone with write access to these backup scripts
# will be able to put commands in them that will be run as the root user.
# If they are malicious, they could take over your server.
#
# chown root:root backup_sqlite.sh
# chmod 700 backup_sqlite.sh
#
##############################################################################
umask 0077
# backup the database
/bin/find /var -iname *.db -exec bash -c ' /usr/bin/file {} | /bin/grep -q "SQLite 3" && /usr/bin/sqlite3 {} ".backup $(/usr/bin/basename {})" ' \;
# make the backup readable only by root
#/bin/chmod 600 filename.db
exit