Current location

narf Source control manager Git

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Mehani <shtrom@ssji.net>2015-03-07 05:42:00 +0100
committerOlivier Mehani <shtrom@ssji.net>2015-03-07 05:42:47 +0100
commit7df4ca1d39115c03105d4c4ee11e9cb1ba48c8c2 (patch)
tree996abb0addfc5e3e98cdcb038581fbb65ed600c3
parentec4e7bd388ac688ec6b2b1b7d057d23072d4b1c4 (diff)
[backup.sh] Add separate configuration file support
Also, better protect LDAP password and give faxe term some ldapvi doesn't fail. Signed-off-by: Olivier Mehani <shtrom@ssji.net>
-rwxr-xr-xopenbsd/backup.sh32
1 files changed, 22 insertions, 10 deletions
diff --git a/openbsd/backup.sh b/openbsd/backup.sh
index f3b609b..83fa2c9 100755
--- a/openbsd/backup.sh
+++ b/openbsd/backup.sh
@@ -1,19 +1,26 @@
#!/bin/sh
-# $Id$
-DIRS="/etc /srv /home/shtrom"
+# The following variables can be overridden in /etc/backup.sh.conf
+DIRS="/etc /srv"
+TMPSUBDIR=/tmp
+
BACKUPROOT="/srv/rdiff-backup"
BACKUPDIR="${BACKUPROOT}/`hostname -s`"
-BACKUPSERVER=backup.narf.ssji.net
-#REMOTEBACKUPDIR="`hostname -s`@${BACKUPSERVER}::${BACKUPDIR}"
-REMOTEBACKUPDIR="`hostname -s`@${BACKUPSERVER}::/share/homes/`hostname -s`"
-EXCLUDEALWAYS="${BACKUPROOT} /srv/backup/ /srv/www/sites/offlines.fr/"
+BACKUPSERVER=backup.example.net
+REMOTEBACKUPDIR="`hostname -s`@${BACKUPSERVER}::${BACKUPDIR}"
+EXCLUDEALWAYS="${BACKUPROOT}"
+
+# enable database backups by specifying non-null *DUMPDIR
MYSQLBINPATH=/usr/local/bin/
MYSQLDUMPDIR="/srv/dbdumps/"
-MYSQLUSER="dumper"
+MYSQLUSER=""
+MYSQLPASS=""
+
LDAPBINPATH=/usr/local/bin/
LDAPDUMPDIR="/srv/dbdumps/"
LDAPUSER="cn=root,dc=example,dc=net"
-TMPSUBDIR=/tmp
+LDAPPASS="secret"
+
+test -e /etc/backup.sh.conf && . /etc/backup.sh.conf
# Dump privilege information [0]
# [0] http://serverfault.com/questions/8860/how-can-i-export-the-privileges-from-mysql-and-then-import-to-a-new-server/13050#13050
@@ -44,9 +51,14 @@ if [ ! -z "$MYSQLDUMPDIR" ]; then
fi
if [ ! -z "$LDAPDUMPDIR" ]; then
+ LDAPPASSFILE=`mktemp` || exit 1
+ cat <<EOF > ${LDAPPASSFILE}
+${LDAPPASS}
+EOF
LDAPDUMP="${LDAPDUMPDIR}ldap.dump.ldiff"
- echo -n " ldap (${LDAPDUMP}) NOT"
- #${LDAPBINPATH}ldapvi --out --host localhost -D ${LDAPUSER} > ${LDAPDUMP}
+ echo -n " ldap (${LDAPDUMP})"
+ TERM=vt100 ${LDAPBINPATH}ldapvi --noninteractive --quiet --noquestions --out --host localhost -D "${LDAPUSER}" -y "${LDAPPASSFILE}" > ${LDAPDUMP}
+ rm -f ${LDAPPASSFILE}
fi
echo "."