Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Debian with Wordpress/ Lighttpd / MySQL/ PhP
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

Debian with Wordpress/ Lighttpd / MySQL/ PhP

plumbergplumberg Veteran

I configured Debian 7 with Lighttpd + MySQL + PHP + Wordpress on a 128MB VPS. All worked fine. Last week, the server HDD crashed and all VPS needed to be re-created. Because it was a small VPS and cheap, the host did not offer any backup. I really did not expect any crashes to happen and I did not have any active content on the VPS. But, I had done a lot of configuration for setting up an optimized version of lighttpd, mysql, php and wordpress manually on the Debian server.

a. Is there any way to backup/ replicate the setup configuration so that I can use it later if needed?
b. Will I be able to restore the configurations on the same vps/ a new vps should something like this happen in future?
c. I also tweaked wordpress. is it possible to simply save the whole wordpress somewhere so that I can restore it without least hassel?

Thanks in advance for your help.

Comments

  • rmlhhdrmlhhd Member
    edited March 2014

    If you can make an SQL dump of the database and copy the config files and move them to the new VPS

  • I personally keep all my websites and config files in a private git repository (with bitbucket), so you're able to quickly deploy it elsewhere if needed. You can also keep database dumps in the same repository.

    Thanked by 1linuxthefish
  • There are several WordPress backup plugins to back up WordPress database and configurations, you can ftp those files to other hosts if you want to.

  • nunimnunim Member
    edited March 2014

    Backing up the server configuration is easy since it does not typically change very often.

    For your webserver config:

    mkdir config-backup
    cp -rf /etc/nginx ./config-backup/
    cp -rf /etc/php5 ./config-backup/
    cp -rf /etc/mysql ./config-backup/
    dpkg --get-selections  > ./config-backup/installed-packages
    tar -cvzf webserver-config.tar.gz  config-backup/
    rm -rfv config-backup

    dpkg --get-selections will give you a list of installed packages so you know exactly what needs to be re-installed.

    Restoring the server configuration would be as simple as installing the packages, renaming those 3 directories, i.e. mv /etc/nginx /etc/nginx-original, then extracting the tar and restarting nginx/php5-fpm/mysql.

    For WordPress you can use a backup plugin, or a simple shell script running on cron job. I prefer the bash script to the plugin as I believe the less WordPress plugins the better and the bash script will be more reliable. i.e.

    mysqldump --force -u wordpress_user -ppassword wordpress > /path/to/wordpresswordpress_db.sql
    tar -cvzf wordpress-backup.tar.gz /path/to/wordpress
    rm -f /path/to/wordpresswordpress_db.sql

    If you have configured a .my.cnf in your home directory, or /root if you're the root user, you probably won't need your username/password included with mysqldump.

    All that's left is to SCP or rsync the backups offsite. I use a very similar process to backup my website's daily.

  • Use mysqldump in an hourly crontab, and use bittorrent sync to sync these files to your desktop or to another cheap VPS.

  • lewekleoneklewekleonek Member
    edited March 2014

    nm I just realized that @nunim got it all nicely wrapped up... removed my comment

  • @nunim, thank you for the detailed instructions. It is amazing. I will try it out this week and see how it comes into play.

    A followup question for WordPress. i setup Wordpress multisite. So, what will be the best way to backup the wp-config and site details? or will I need to configure it separately all the time?

  • i prefer to use script like tuxlite to build my server

  • nunim said: dpkg --get-selections > ./config-backup/installed-packages

    Great tip, @nunim, thanks!

    And if I googled my Google correctly, to reinstall packages from that list you would:

    dpkg --set-selections < installed-packages
    apt-get dselect-upgrade
    
  • I put all of my config directories (nginx, php5-fpm, etc) into a git repo and commit every time I make a change.

    It has the added advantage of allowing me to rollback if I make any mistakes.

Sign In or Register to comment.