Last active
July 25, 2016 00:56
-
-
Save JamieWritesCode/93933b2bddb55fcb509b2810189c4a24 to your computer and use it in GitHub Desktop.
Installs and configures AutoMySQLBackup with a post backup script to change ownership of backups to the default user 'forge' on Laravel Forge.
This file contains hidden or 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
# Install automysqlbackup | |
apt-get -y --force-yes install automysqlbackup | |
# Create post backup script | |
mkdir -p /home/forge/scripts | |
cat >/home/forge/scripts/mysql-backup-post.sh <<"EOF" | |
#!/bin/bash | |
find /var/lib/automysqlbackup -type f -exec chown root:forge {} \; -exec chmod 740 {} \; | |
find /var/lib/automysqlbackup -type d -exec chown root:forge {} \; -exec chmod 770 {} \; | |
exit 0 | |
EOF | |
chmod u+x /home/forge/scripts/mysql-backup-post.sh | |
# set default configuration to use mysql-backup-post.sh | |
declare -A replacers | |
replacers[POSTBACKUP]="/home/forge/scripts/mysql-backup-post.sh" | |
for i in "${!replacers[@]}" | |
do | |
echo "Uncommenting $i if commented" | |
perl -pi -e "s/^# *$i/$i/" /etc/default/automysqlbackup | |
echo "Setting value of $i to ${replacers[$i]}" | |
sed -i "s@^\($i\).*@\1=${replacers[$i]}@" /etc/default/automysqlbackup | |
done | |
# run it (also creates cron jobs) | |
automysqlbackup |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment