Created
October 6, 2018 15:05
-
-
Save franckweb/845adfe0842231692b27da94c77a970a to your computer and use it in GitHub Desktop.
Move non-Virtualmin accounts into Virtualmin transferring data and databases
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
# Move non-Virtualmin accounts into Virtualmin transferring data and databases | |
# When its done update config files | |
# TODO: automate the updating of common config files | |
# Connects to the destination server to create the Virtualmin server | |
#Then connects to the source to move files and databases across | |
set -e | |
# New Site Settings | |
site_domain="domainname.co.uk" | |
# Source Server Details | |
source_server="myhostserver.co.uk" source_username="accountname" source_db="account_website" | |
# Destination Server Details | |
dest_server="mydestserver.co.uk" dest_username="domainname" dest_db="domainname" dest_pass="123456789" dest_desc="Site Description" dest_sqlpass="987654321" | |
# CREATE DOMAIN # | |
ssh root@"$dest_server" "virtualmin create-domain --domain $site_domain --pass $dest_pass --desc '$dest_desc' --unix --dir --webmin --web --mail --mysql --limits-from-plan --mysql-pass '$dest_sqlpass' --fwdto 'info@mywebsite.co.uk'" | |
# COPY FILES # | |
ssh root@"$source_server" "rsync -avz -e ssh --progress /home/$source_username/public_html/ root@$dest_server:/home/$dest_username/public_html/" | |
# DUMP DB # | |
ssh root@"$source_server" "mysqldump $source_db > /home/$source_username/$source_db.sql" | |
# COPY DB FILES # | |
ssh root@"$source_server" "scp /home/$source_username/$source_db.sql root@$dest_server:/home/$dest_username/$dest_username.sql" | |
# RESTORE DB FILES # | |
ssh root@"$dest_server" "mysql $dest_db < /home/$dest_username/$dest_username.sql" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment