Bruker:Mihho/db-backup.sh

Fra IThjelp
#!/bin/bash

LISTA=`find /var/lib/mysql/ -maxdepth 1 -type d | awk -F '/' '{print $5}' | sort | uniq | sed '/^$/d'`

# Find all databases, make the necessary mysqldump command, save it to a runme.sh file which can be run after
for i in $LISTA; do echo "cd /backup/helge; mysqldump --lock-tables=false $i  > /backup/helge/$i.$(date +%Y-%m-%d:%T).sql"; done > /backup/helge/runme.sh
echo "cd /backup/helge/; gzip *.sql" >> /backup/helge/runme.sh

# make it runable
chmod 755 /backup/helge/runme.sh

# Go backup!
/backup/helge/runme.sh

# Save the commands in the runme.sh file to a local git repo?
cd /backup/helge/
git commit -m "runme.sh: db-backup kommandoene" runme.sh

exit;