Skip to content

Instantly share code, notes, and snippets.

Last active Mar 13, 2016
What would you like to do?
VPS Migration Script (personalized)
echo -n "Enter your MySQL root password, followed by [ENTER]: "
read mysqlrootpwd
echo -n "Enter your remote hosts root password, followed by [ENTER]: "
read remoterootpwd
apt-get -y update;
apt-get -y upgrade;
apt-get -y install sshpass;
apt-get -y install openssh-server ssh apache2 mysql-server php5 phpmyadmin postfix rsync gzip zip unzip screen nodejs php-pear php5-curl htop php-gettext;
cat /dev/zero | ssh-keygen -q -N ""
echo $remoterootpwd > /tmp/rootpass.txt
sshpass -f /tmp/rootpass.txt ssh-copy-id
rm -rf /etc/apache2/sites-available/
rm -rf /etc/apache2/sites-enabled/
scp -r /etc/
scp -r /etc/apache2/httpd.conf
scp -r /etc/apache2/
scp -r /etc/apache2/
scp -r /etc/apache2/
scp -r /etc/
scp -r /usr/lib/
ssh "rm -f /tmp/*.zip; cd /tmp; zip -r /root/;"
scp -r /tmp/
ssh "cd /tmp; zip -r /var/www/;"
scp -r /tmp/
ssh "cd /tmp; rm -f /tmp/sqldump*; mysqldump -uroot -p${mysqlrootpwd} --single-transaction --routines --triggers --all-databases > /tmp/sqldump.sql; gzip /tmp/sqldump.sql;"
scp -r /tmp/
cd /tmp
gunzip -f /tmp/sqldump.sql.gz
mysql -uroot -p${mysqlrootpwd} < /tmp/sqldump.sql
rm -rf /root/
mv /tmp/root/ /
rm -rf /var/www/
mv /tmp/var/www/ /var/
a2enmod ssl
a2enmod proxy
a2enmod proxy_http
a2enmod cgi
a2enmod ldap
a2enmod rewrite
scp -r /etc/
scp -r /usr/local/
ssh "crontab -l > /tmp/crontab;"
scp -r /tmp/
crontab /tmp/crontab
chown -R www-data: /var/www/
sed -i 's/AllowOverride None/AllowOverride all/g' /etc/apache2/apache2.conf
sed -i 's/Options FollowSymLinks/Options +FollowSymLinks -Indexes/g' /etc/apache2/apache2.conf
echo "StartServers 1
MinSpareServers 1
MaxSpareServers 5
ServerLimit 16
MaxClients 16
MaxRequestsPerChild 0
ListenBacklog 100
" >> /etc/apache2/apache2.conf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment