Restoring/moving crashed Debian 5 datas to VM debian 7

I used to have an old PC on Debian 5 for web development.

But when trying to upgrade it to debian 6, well the system never booted back.
As I’m not a Linux master at all, I never came to get it back to life.
Still I needed my web dev environment and decided to recover and move datas to a VM.

Why a VM , snapshots are much easier to make and manage and Time Machine can also backup it…

I didn’t succeed in my first attempt but I finally did succeed and here are the steps I followed.

First things first install a new VM.

I use Parallels on my Mac.
Download debian-7.2.0-amd64-CD-1.iso and make the install.
I choose Options like apache php mysql dns and Gnome3 GUI (yeah I like GUI if I can)

Take the Hard drive out of the old PC.

It was an IDE hard drive and hopefully I still have an external enclosure.

Once the VM was installed and running with default settings, plug it in via USB and assign it to the VM (if you like).

Parallels tools.

I’ll install Parallels Tools later on (it fails) as I don’t care at all that it is isolated from the Mac.
I use SSH / FTP via Coda so I don’t care. Clipboard sharing is annoying but it’s ok.

Here are the steps I’ll followed and installs I did:

Install gnome System Utilities, allow root login (Warning security issue here), install Webmin, apache2, php5, mysql-server, mysql-workbench, phpmyadmin, Proftpd, Parallels tools (not yet). Plus all the prerequities needed for those.

Take a snapshot if you’re on VM

(you should do so before any new install/modification, trust me on this ;) )

GNOME 3 failure to start at login.

I have an annoying message stating that gnome3 fails to start. this is surelly because I don’t have parallels tools installed yet, but I’m not sure I will do so.

Logged in as Admin:

sudo apt-get install libgl1-mesa-dri-experimental

Note : needs to reboot so gnome3 is finally OK. see the bottom of the page for the original source.

Install Users management GUI tool:

Even though we can do commandline, this is way much easier sometimes to deal with system settings such as creating new Users and groups for example.

sudo apt-get install gnome-system-tools

one liner to get parallels tools + root login:

sudo apt-get install make gcc build-essential linux-headers-$(uname -r) libgl1-mesa-dri-experimental gnome-system-tools

Note : parallels needs gcc linux headers and build essential before you can install it.

Allow root login

Things have changed from Debian 5 here are the step so you can login as root.
you have to edit the file /etc/gdm3/daemon.conf. Find the [security] line and add those 2 lines.

nano /etc/gdm3/daemon.conf


and edit the file /etc/pam.d/gdm3 on line2 comment it out with #.

nano /etc/pam.d/gdm3
#auth required user != root quiet_success

I’m now Logged in as root.

Take a snapshot :)

Webmin prereq & install

As stated on the webmin install page, you should also fetch and install the GPG key with which the repository is signed, with the commands :

cd /root
apt-key add jcameron-key.asc

apt-get install perl libnet-ssleay-perl openssl libauthen-pam-perl libpam-runtime libio-pty-perl apt-show-versions python

dpkg --install webmin_1.660_all.deb

Webmin should now be installed and running and you should be able to connect to https://localhost:10000

Take a snapshot

Next, other installs

apt-get install mysql-server phpmyadmin libapache2-mod-python php5 libapache2-mod-php5 libapache2-svn

Take a snapshot

Now the real stuff : Restoring and moving datas and config files.

stopping apache2 and mysql

service apache2 stop
service mysql stop

Note: apache2 config was “simple”; no need (so I think) to copy apache config.
I Only need mysql db and config files. and the /var/www contents of course.

Restore www & mySQL // Step 1

Still logged in as root.
Remeber I have my external IDE drive mounted.
It is /media with a very long string as the name.

As we are wise, we backup the original datas on the VM, then copy the datas from the external drive to the VM.

Restoring mysql files:

cd /media/someweirduglynumbers/var/lib

mv /var/lib/mysql /var/lib/mysql.dist
cp -a mysql /var/lib/mysql
chown -R mysq:mysql /var/lib/mysql
chmod 700 mysql

mv /etc/mysql /etc/mysql.dist
cd ../../etc
cp -a mysql /etc

Restoring web files:

For now I’ll copy only 1 site to test (it is a wordpress).
If all is ok, I’ll copy the remaining sites datas…

cd ../var/www
cp -a site1 /var/www

restarting apache2 and mysql

service apache2 start
service mysql start

And connect to http://localhost/site1

ALL GOOD ! I can access to front and back office.

Take a snapshot

I have a permalink pb, see below it is just a simple AllowOverride all that was missing in apache2.conf.
But all is quite good as I can access the back office and I see all posts and categories, users, etc…

AS I said, I had a basic apache2 config… on the Debian5 (all is in /var/www) with subdomains etc…
meaning I access the sites with urls like :



and so on.

I will just manage to copy mysql config and data. (and it is done)
and only copy the /var/www
I will not copy the /etc/apache2 nor php5 config files.
I did it previously but I had too many errors. debian 5 to 7 has too many changes.

Next copy the /var/www files from old disc to new VM.
We backup the /var/www folder first (I remove the site1 before)

rm -Rf /var/www/site1
cd /media/someweirduglynumbers/var/
mv /var/www /var/www.dist
cp -a www /var

Take a snapshot

install mysql-client mysql-workbench

apt-get install mysql-client mysql-workbench

phpmyadmin 404 error

For unknown reason the phpmyadmin install did not changed the apache2 config files. leading to a 404 error. Let’s repair that

ln -s /etc/phpmyadmin/apache.conf /etc/apache2/sites-enabled/phpmyadmin

Working now ;)

phpmyadmin repair all tables for all databases

I did not said it but when starting mysql I have a warning. so via phpmyadmin I’ve repaired all tables of all databases (not the mysql nor the phpmyadmin). Please note that the repair doesn’t work for innodb files. I’ll deal with that later.

resolving the permalink issues for wordpress and prestashop.

Modrewrite was simply not active

a2enmod rewrite
service apache2 restart

ANd we need to AllowOveride All
So I changed the file /etc/apache2/sites-available/default

nano /etc/apache2/sites-available/default
AllowOveride All

Permalinks are now working fine. All is good.

Take a snapshot

I also Deleted all Bad Snapshots from my previous attempt to get a clean VM.

installing FTP access and assign a password for www-data

I use CODA and I need FTP access to push files,
and I login via www-data user so that I don’t have permissions pb.

I Installed proftpd via webmin -> modules -> FTP.

I had an error and it didn’t appeared in the left Server tab of webmin,
so I forced apt-get install via webmin and it was OK.

Adding password to www-data user

passwd www-data

Or you could use the gnome System utilities we did install at the begining ;)

I have now restored my web dev environment, CODA didn’t screamed and connect fines with no erros just like nothing had changed.

Some notes:

In parallels, I first assigned the MAC address of the old PC to the New VM.
I then use a live ubuntu CD, launch a Terminal and noted it via ifconfig.
Because I’ve not the hand on the DNS company where and I wanted the VM to get the same IP.

In my ssh knownhosts I had to remove my old PC, then connect to it once via terminal.

Coda then was ok, and I’m back to work.

I hope that thoses steps may help you too.

Sources that were helpfull :

Gnome3 failure. ([]

Moving a LAMP server : ([]


Product and graphic designer turned to be a Mac SysAdmin.

Posted in Admin, Linux Tagged with: , , , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>