Skip to content

Instantly share code, notes, and snippets.

@SelStrom
Created August 18, 2016 18:03
Show Gist options
  • Save SelStrom/2a15fd4539959868dc750a0f0d2dee9a to your computer and use it in GitHub Desktop.
Save SelStrom/2a15fd4539959868dc750a0f0d2dee9a to your computer and use it in GitHub Desktop.
Scripts to copy castom db to remote server
#!/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
#!/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