Skip to content

Commit

Permalink
Initial blob commit:
Browse files Browse the repository at this point in the history
* Added GPLv3 license
* README for configuration
* example for cron.daily
* The script it self (owncloud-db-backup.sh)
  • Loading branch information
fmikker committed Aug 22, 2015
0 parents commit 04f96ec
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 0 deletions.
14 changes: 14 additions & 0 deletions owncloud-db/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Copyright 2015 Fredrik Mikker <[email protected]>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
13 changes: 13 additions & 0 deletions owncloud-db/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Simple script to do a local database backup of a owncloud instance, to be fetched later by the system backup (In this case Bacula).

Intended for a Owncloud instance running in CentOS 7 with systemd, which utilizes the internal journal instead of log files by pipe-ing to systemd-cat, which is sent to a central syslog server (op5 Logger).

Usage:

1. Copy owncloud-db-backup.sh to a suitable folder for binaries (/root/bin/ in my case)
1.2: Change the settings in the script to correspond to your user, password and database name.
2. Use the cron file supplied and put it in /etc/cron.daily/
3. Test the functinality by using run-parts:
# run-parts /etc/cron.daily/ -v
4. Monitor your system journal to confirm that the log messages is written:
# journalctl -f
2 changes: 2 additions & 0 deletions owncloud-db/owncloud-db-backup.cron
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
/root/bin/owncloud-db-backup.sh 2>&1
18 changes: 18 additions & 0 deletions owncloud-db/owncloud-db-backup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash
mysqldump --lock-tables -u <INSERT USERNAME> -p<INSERT PASSWORD> owncloud_data > /owncloud/backup/owncloud-sqlbkp_`date +"%Y%m%d"`.bak

if [ $? -eq 0 ]

then

echo "Owncloud database backup successful" | systemd-cat --identifier "owncloud-db-backup" --priority "info"

exit 0

else

echo "Owncloud database backup failed!" | systemd-cat --identifier "owncloud-db-backup" --priority "warn"

exit 1

fi

0 comments on commit 04f96ec

Please sign in to comment.