File: backup_sqlite.sh

package info (click to toggle)
rsnapshot 1.5.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,328 kB
  • sloc: perl: 4,833; sh: 345; ruby: 232; makefile: 90
file content (37 lines) | stat: -rw-r--r-- 1,277 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash

##############################################################################
# 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 -type f -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 *.db

exit