• Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.

need feedback on linux backup script

Joined
Sep 5, 2004
Messages
1,874 (0.38/day)
Likes
256
Location
The Kingdom of Norway
System Name Wiak's Gaming Rig 2017
Processor Ryzen 1700X
Motherboard ASUS PRIME X370-PRO
Cooling Noctua
Memory Corsair Vengenace LPX 3200 CL16 @ 2933
Video Card(s) MSI Radeon 480 8GB Gaming X
Storage Samsung 960 EVO 500GB / Samsung 850 EVO 1TB
Case Corsair 200R
Power Supply Corsair AX850
Mouse Corsair Sabre Laser
Keyboard Logitech Orion Brown (G610)
#1

W1zzard

Administrator
Staff member
Joined
May 14, 2004
Messages
17,152 (3.43/day)
Likes
18,102
Processor Core i7-4790K
Memory 16 GB
Video Card(s) GTX 1080
Display(s) 30" 2560x1600 + 19" 1280x1024
Software Windows 7
#2
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

Code:
#!/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
 
Joined
Sep 5, 2004
Messages
1,874 (0.38/day)
Likes
256
Location
The Kingdom of Norway
System Name Wiak's Gaming Rig 2017
Processor Ryzen 1700X
Motherboard ASUS PRIME X370-PRO
Cooling Noctua
Memory Corsair Vengenace LPX 3200 CL16 @ 2933
Video Card(s) MSI Radeon 480 8GB Gaming X
Storage Samsung 960 EVO 500GB / Samsung 850 EVO 1TB
Case Corsair 200R
Power Supply Corsair AX850
Mouse Corsair Sabre Laser
Keyboard Logitech Orion Brown (G610)
#3
cool danke! :)
/ich jaster ein beer @ w1zzard

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