From 6d96fb5edb785e60f25e86ef36532c6c60331cdb Mon Sep 17 00:00:00 2001 From: Bryan Date: Sun, 20 Sep 2020 00:26:50 -0600 Subject: [PATCH] Edit README.md, add instructions for special files. Flesh out special dump functions. --- README.md | 21 +++++++++++++++++++++ src/borgwrapper | 36 ++++++++++++++++++++++++++++++++++++ src/config.example | 5 ++++- 3 files changed, 61 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 75c5a0a..72838e8 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,27 @@ Ensure restrictive permissions on this file as it exposes the passphrase. chown root. config chmod 600 config +## Special files +To be able to dump special files there are a few things that need to be done. +### Installed package list +Must have the package **apt-mark** installed. +### MySql Dump +Must have the package **mysqldump** installed. +Must have `.my.cnf` configuration file in `/root` directory. + +Create `.my.cnf` in `/root` directory: + + [mysql] + user="root" + password="mysql-root-password" + + [mysqldump] + user="root" + password="mysql-root-password" + +Change permissions of `.my.conf`: + + chmod 600 /root/.my.conf # Scheduling ## systemd diff --git a/src/borgwrapper b/src/borgwrapper index 40d4798..bf67f05 100755 --- a/src/borgwrapper +++ b/src/borgwrapper @@ -31,6 +31,42 @@ error_handler () { exit ${EXIT_CODE} } +save_package_list () { + if ! which apt-mark; then + return 2 + fi + + if [ ! -d dirname "${PACKAGE_LIST_FILE}" ]; then + mkdir -p dirname "${PACKAGE_LIST_FILE}" + fi + + apt-mark showmanual > ${PACKAGE_LIST_FILE} +} + +dump_sql () { + if ! which mysqldump; then + return 2 + fi + + if [ ! -d dirname "${MYSQL_DUMP_FILE}" ] + then mkdir -p dirname "{$MYSQL_DUMP_FILE}" + fi + + +} + +dump_mongo () { + if ! which mongodump; then + return 2 + fi + + if [ ! -d dirname "${MONGODB_DUMP_FILE}" ] + then mkdir -p dirname "{$MONGODB_DUMP_FILE}" + fi +} + + + borg_init () { if [[ -z ${BORG_INIT_ARGS[@]} ]]; then BORG_INIT_ARGS=( diff --git a/src/config.example b/src/config.example index d39c584..48fa786 100644 --- a/src/config.example +++ b/src/config.example @@ -7,7 +7,10 @@ BORG_REPO="@:/srv/borg/${SYSTEM_NAME}" #BORG_REPO="ssh://@:/srv/borg/${SYSTEM_NAME}" BORG_PASSPHRASE="longandcomplexpassphrase" -DUMP_DIR="/srv/dumps" +PACKAGE_LIST_FILE="/srv/dumps/package-list.txt" +MYSQL_DUMP_FILE="/srv/dumps/mysql-dump.sql.bak" +MONGODB_DUMP_FILE="/srv/dumps/mongodb-dump.bak" + MYSQL_ROOT_PASSWORD="" MONGODB_ROOT_PASSWORD=""