User Tools

Site Tools


Restoring a Debian server from a backup

This article assumes that the files are in the standard locations.

Set the following variable to where you have the copy of the restored files.

export restore_dir='/restore'

Restoring Postfix and Dovecot

Precondition: home directories restored (contain IMAP directories).

  1. Ordered List ItemInstall Postfix and Dovecot like descirbed in the articles.
  2. Stop the services.
  3. Move away the standard configuration
  4. Restore mail aliases and
mv /etc/postfix /etc/postfix.old
mv /etc/dovecot /etc/dovecot.old
cp -a $restore_dir/var/mail/* /var/mail/
cp -a $restore_dir/etc/aliases $restore_dir/etc/mailname /etc
postalias /etc/aliases
service saslauthd start
service postfix start
service dovecot start

Restoring MySQL

Variant a) Quick and dirty: restore by replacing files.

<note>This is a dangerous variant since there can be incompatibilities between MySQL versions that affect the storage format. Also it is not guaranteed that the files were in a consitent state when they were backed-up if the server was running. In any case exporting and importing the database is much safer!</note>

service mysql stop
cp -a /var/lib/mysql /var/lib/mysql.old

Restore each database:

cp -a $restore_dir/var/lib/mysql/<database> /var/lib/mysql

Restore Wordpress

mv /etc/wordpress /etc/wordpress.old
cp -a $restore_dir/etc/wordpress /etc

Start the server

service mysql start

Check if you can see the

echo 'show databases' | mysql -u root -p

Follow the instructions to download and install the package from the article “Installation on Debian” up to the point where the configuration dialogs start.

In the dialogs choose not to install a default database since you are going to restore an existing database.

We discussed the q&d variant of restoring a MySQL database earlier. If you have an SQL dump use that instead of the file copy method below.

service mysql stop
cp -a $restore_dir/var/lib/mysql/gallery3 /var/lib/mysql
chown -R mysql:mysql /var/lib/mysql/gallery3/
service mysql start

Check if MySQL sees the database:

echo 'show databases' | mysql -u root -p gallery3

Now add the missing gallery database user with the appropriate permissions:

GRANT SELECT, INSERT, LOCK TABLES, UPDATE, DELETE, ALTER ON gallery3.* TO gallery3@localhost IDENTIFIED BY '<password>';
FLUSH privileges;

Restore the configuration files and the collected photos and albums (this may take a while):

cp -a $restore_dir/etc/gallery3/* /etc/gallery3/
cp -a $restore_dir/var/lib/gallery3/* /var/lib/gallery3/

Don't forget to restore the Apache configuration (not described here since this is different for almost each installation).

If gallery gives you a warning that PHP's “short open tag” feature is required, you need to enable it in the php.ini:

sed -ie 's/^short_open_tag *=.*/short_open_tag = On/' /etc/php5/apache2/php.ini

Restoring "awstats"

Install awstats as described in the corresponding article up to the point before you fix the permissions.

Copy the old files over:

cp -a $restore_dir/var/lib/awstats/* /var/lib/awstats/

Now fix the permissions like in the article.

restoring_debian_from_backup.txt · Last modified: 2015/06/28 22:09 by sebastian