Skip to content

Instantly share code, notes, and snippets.

@dogmatic69
Created April 22, 2011 00:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dogmatic69/935747 to your computer and use it in GitHub Desktop.
Save dogmatic69/935747 to your computer and use it in GitHub Desktop.
moving aws locations
// log into the old server
ssh -i <key_file> ubunut@<old_ip>
// login as root
sudo su
// tar the entire drive skipping a few dirs
tar -cvpzf backup.tar.gz --exclude=~/backup.tar.gz --exclude=/proc --exclude=/lost+found --exclude=/sys --exclude=/mnt --exclude=/media --exclude=/dev /
// copying the files from the old server to the new server
scp -i <key_file> backup.tar.gz ubuntu@<new_ip>:~/
// exit the server
exit
// log into the new server
ssh -i <key_file> ubuntu@<new_ip>
// unzip the backup and overwrite everything on the new instance (lazy install)
sudo tar -xvpzf backup.tar.gz -C /
// fixing up sources on the new server
sudo nano /etc/apt/sources.list
// when nano opens find and replace the old with the new
ctrl + \
// you will be given the following
// - find what
// - replace with
// - [a] for all
// when done save and exit, on the keyboard hit
ctrl + o // save
ctrl + x // exit
// clean apt-get
sudo apt-get clean
cd /var/lib/aptsudo
// always backup
mv lists lists.old
// fooling it to thing there was a partial update?
sudo mkdir -p lists/partial
// update the server
sudo apt-get update
// oh I do love pipe, this downloads the key from the ubuntu server and pipes the text to apt-key add
wget -q "http://keyserver.ubuntu.com:11371/pks/lookup?op=get&search=0x<key_it_complained_about>" -O- | sudo apt-key add -
// updates should now work
sudo apt-get update
sudo apt-get upgrade
// \o/
// remove anything mysql related
sudo yes | apt-get remove mysql-*
// install all the mysql stuff you need again
sudo yes | apt-get install mysql-server php5-mysql
// dont forget to add your users back and/or run your database buckup
// save this to ~/.ssh/config
host <some-cool-name>
Port <port>
User <user>
HostName <host>
// fill out the stuff in <here> and then use it like 'ssh <some-cool-name>'
// you can also do ssh some<tab> for auto complete :)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment