Created
August 18, 2016 18:03
-
-
Save SelStrom/2a15fd4539959868dc750a0f0d2dee9a to your computer and use it in GitHub Desktop.
Scripts to copy castom db to remote server
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 | |
#set -x | |
/etc/init.d/mysql stop | |
cp -R /var/lib/mysql/$1 /home/backup/ #copy /home/backup/ reqursively | |
cd /home/backup/ | |
tar -zcvf $1.tar.gz $1 #archive this | |
scp $1.tar.gz <user>@<host>:/home/$1.tar.gz //like root@XXX.xxx.xxx.xxx | |
#dont forget to set unix-style line endings |
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 | |
#set -x | |
/etc/init.d/mysql stop | |
cd /home | |
tar -xvf $1.tar.gz -C /home/inputtables/ | |
mv /var/lib/mysql/$1 /home/backup/ | |
mv /home/inputtables/$1 /var/lib/mysql/ | |
chown mysql:mysql -R /var/lib/mysql/$1 | |
cd /var/lib/mysql/$1 | |
chmod 660 -R * | |
/etc/init.d/mysql start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment