# need feedback on linux backup script



## wiak (Apr 9, 2013)

i made a backup script and i need some feedback
https://www.dropbox.com/s/htd59bcurk8a5f3/triforce.v1.1.withcleanup.sh (viewable in browser)


----------



## W1zzard (Apr 9, 2013)

simple enough. please be aware that mysqldump will lock your databases for while it runs.

might want to consider gzip with lower compression for more throughput

i also recommend to split the database dumps into one file per database.. MUCH easier to restore individual stuff then


```
#!/bin/bash

umask 0077                                                                                                                                                                                
# MySQL Login details
MYSQLUSER="root"
MYSQLPASSWORD=""

for DATABASE in `echo 'show databases' | mysql --column-names=false --password=$MYSQLPASSWORD`
do
#        echo -n "Exporting database $DATABASE to $DATABASE.sql ... "
        /usr/bin/mysqldump --quick --add-drop-table --add-locks \
                --extended-insert --password=$MYSQLPASSWORD \
                --user=$MYSQLUSER --opt $DATABASE | gzip -f -9 > $DATABASE.sql.gz
        /bin/chmod 600 $DATABASE.sql.gz
        BYTES=`stat -c "%s" $DATABASE.sql.gz`
        BYTES=`echo "scale=2; $BYTES/1024" | bc`
#        echo "Compressed to $BYTES KBytes."
done
```

we use that on a replication slave so it doesn't lock our main database

google rsnapshot for a wonderful free general purpose backup tool


----------



## wiak (Apr 9, 2013)

cool danke! 
/ich jaster ein beer @ w1zzard

trying out memrise.com 
sorry if i offend you with my deutch


----------

