Last active
September 18, 2024 22:14
-
-
Save suuhm/99dd131add5ffad645e10eb2f742a383 to your computer and use it in GitHub Desktop.
Froxlor Smart Backup - (Auto) Update - Restore Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# FROX_BACKUPDATER SCRIPT | |
# | |
# FEATURES: BACKUP (DEFUALT) / UPDATE LATEST VERSION / RESTORE BACKUP | |
# | |
# COPYRIGHT 2020 SUUHMER | |
# DEV.COLDWAREVERYDAY.COM | |
# | |
# USAGE: | |
# frox_backupdater.sh [--backup | --update [--backup] | --restore BACKUPFILE.bak.tar.gz DBBACKUPFILE.bak.sql [--backup] ] | |
# | |
# CONFIGS | |
_backupdir="/backups/froxlor" | |
_froxdir="/var/www/froxlor" | |
_frox_db_name="froxlor" | |
#FILE=$2 | |
FILE=https://files.froxlor.org/releases/froxlor-latest.tar.gz | |
# END CONFIGS | |
_datetime=`date +'%d%m%Y'` | |
_backup() { | |
# Default setup backup-dir: | |
mkdir -p $_backupdir | |
cd $_backupdir | |
echo | |
echo "Starting backup of Document dir:" | |
sleep 2 | |
tar -czf frox."$_datetime".bak.tar.gz $_froxdir/* | |
echo "Backup directory done.. now make Mysql Backup:" | |
sleep 2 | |
echo | |
echo "Please input Mysql password (root):" | |
echo | |
#maybe todo gzip with all dbs? | |
#mysqldump -u root -ppasswod --all-databases | gzip > dbserver-full.sql.gz | |
mysqldump -uroot -p $_frox_db_name > frox."$_datetime".bak.sql | |
echo | |
echo "Copy Userdata file..." | |
cp -a $_froxdir/lib/userdata.inc.php . >/dev/null 2>&1 | |
echo "Backup done dir: ($_backupdir)" | |
echo | |
} | |
# Backup only | |
if [ $2 == "--backup" ]; then | |
_backup | |
fi | |
#set the update froxlor: | |
if [[ $1 == "--update" ]]; then | |
echo "Starting update froxlor..." | |
sleep 2 | |
if [ $2 == "--backup" ]; then | |
_backup | |
fi | |
wget $FILE | |
# Verbose debug -v | |
tar -xzf $(basename $FILE) -C $_froxdir --strip-components=1 | |
cp -a $_backupdir/userdata.inc.php $_froxdir/lib/ >/dev/null 2>&1 | |
rm -f $(basename $FILE) | |
echo "Update done, now finish online.." | |
#restore froxlor backups: | |
elif [[ $1 == "--restore" ]]; then | |
echo "Starting update froxlor..." | |
sleep 2 | |
if [ $4 == "--backup" ]; then | |
_backup | |
fi | |
# Verbose debug -v | |
tar -xzf $2 -C $_froxdir --strip-components=1 | |
#cp -a $_backupdir/userdata.inc.php $_froxdir/lib/ | |
#gunzip < sql-backup.bak.sql.gz | mysql -u root -ppassword $_frox_db_name | |
mysql -uroot -p $_frox_db_name < $3 | |
echo | |
echo "-------------------------------------------------" | |
echo " Update done! Now finish ur installation online. " | |
echo "-------------------------------------------------" | |
fi | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment