summaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2009-04-30 13:15:17 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2009-04-30 13:15:17 +0000
commit34a5c86beeabea8b36c96457931bfe17577b85e1 (patch)
tree7fab9f08eaa7d6914c1613c543239b76dc4bd62c /contrib
parent465f11ec6676d03716a484b9f148246db87087b8 (diff)
downloadampache-34a5c86beeabea8b36c96457931bfe17577b85e1.tar.gz
ampache-34a5c86beeabea8b36c96457931bfe17577b85e1.tar.bz2
ampache-34a5c86beeabea8b36c96457931bfe17577b85e1.zip
added ampache db dump script, thanks Huufarted
Diffstat (limited to 'contrib')
-rw-r--r--contrib/scripts/ampache_db_dump.sh46
1 files changed, 46 insertions, 0 deletions
diff --git a/contrib/scripts/ampache_db_dump.sh b/contrib/scripts/ampache_db_dump.sh
new file mode 100644
index 00000000..75a17b4a
--- /dev/null
+++ b/contrib/scripts/ampache_db_dump.sh
@@ -0,0 +1,46 @@
+#!/bin/bash
+
+###############################################
+# CHANGE THESE OPTIONS TO MATCH YOUR SYSTEM ! #
+###############################################
+
+cfgfile=/etc/ampache/ampache.cfg.php # Ampache config file
+ampachedir=/usr/share/ampache/www # the directory Ampache is installed in
+backupdir=~/ampache_backup # the directory to write the backup to
+
+###############################################
+# END OF CONFIGURABLE OPTIONS #
+###############################################
+
+ampacheDBserver=`grep "^database_hostname" $cfgfile | cut --delimiter="=" -f2 | cut --delimiter="\"" -f2`
+ampacheDB=`grep "database_name" $cfgfile | cut --delimiter="=" -f2 | cut --delimiter="\"" -f2`
+ampacheDBuser=`grep "database_username" $cfgfile | cut --delimiter="=" -f2 | cut --delimiter="\"" -f2`
+ampacheDBpassword=`grep database_password $cfgfile | cut --delimiter="=" -f2 | cut --delimiter="\"" -f2`
+
+mysqlopt="--host=$ampacheDBserver --user=$ampacheDBuser --password=$ampacheDBpassword"
+
+timestamp=`date +%Y-%m-%d`
+
+dbdump="$backupdir/ampache-$timestamp.sql.gz"
+filedump="$backupdir/ampache-$timestamp.files.tgz"
+
+date
+echo "Ampache backup."
+echo "Database: $ampacheDB"
+echo "Login: $ampacheDBuser / $ampacheDBpassword"
+echo "Directory: $ampachedir"
+echo "Backup to: $backupdir"
+echo
+echo "creating database dump..."
+mysqldump --default-character-set=utf8 $mysqlopt "$ampacheDB" | gzip > "$dbdump" || exit $?
+
+echo "creating file archive of $ampachedir ..."
+cd "$ampachedir"
+tar --exclude .svn -zcf "$filedump" . || exit $?
+
+echo "Done!"
+echo "Backup files:"
+ls -l $dbdump
+ls -l $filedump
+echo "******************************************"
+echo