Page 1 of 3 123 LastLast
Results 1 to 10 of 28

Thread: Web Server Backups

  1. #1
    Join Date
    Feb 2010
    Location
    QLD, Australia
    Beans
    491
    Distro
    Kubuntu 12.04 Precise Pangolin

    Web Server Backups

    The Server in question is actually my friends CentOS Web server. But as I'm not apart of the CentOS forums as I don't use it, I thought I'd ask here.

    My question is; What backup methods or software do people recommend for backing up a Web Hosting Server? It needs to be easy to restore either individual files and the full backup. And also be able to backup to a local network share.

    In the past I have always used tar as explained in http://ubuntuforums.org/showthread.php?t=35087 and have had no trouble with it, I now currently use Deja-dup on my own personal desktop. However I want to know is this still a good valid method for a web server? or can someone suggest something better. I'd like to be able to do occasional full backups as well as on going incremental backups.
    Ubuntu 12.04
    “To mess up a Linux box, you need to work at it; to mess up your Windows
    box, you just need to work on it”.
    TrinhamTechnologies.com.au

  2. #2
    Join Date
    Nov 2008
    Location
    Metro Boston
    Beans
    9,001
    Distro
    Kubuntu 14.04 Trusty Tahr

    Re: Web Server Backups

    I use rsync to transfer the web directories to an offsite machine, and a script that runs pg_dump to back up my PostgreSQL databases to text files. I then suck those over with rsync as well.

    Tar is fine, but you need to untar to archive if you want to restore a specific file.

    If you want to have rotations, then you'd need to write a script that creates a new directory each day and copies that day's snapshot to the backup server with rsync.
    If you ask for help, please have the courtesy to check for responses and thank the people who helped you.

    Blog · Linode System Administration Guides · Android Apps for Ubuntu Users

  3. #3
    Join Date
    Feb 2010
    Location
    QLD, Australia
    Beans
    491
    Distro
    Kubuntu 12.04 Precise Pangolin

    Re: Web Server Backups

    I had thought about using rsync. how do you get rsync to copy to another dir for each day and only copy the updated file instead of everything?

    Also you mentioned that you ran a seperate script for you SQL databases, is that needed to back them up or do you just preffer it? Would it work for MYSQL?

  4. #4
    Join Date
    Nov 2008
    Location
    Metro Boston
    Beans
    9,001
    Distro
    Kubuntu 14.04 Trusty Tahr

    Re: Web Server Backups

    Backing up a MySQL or PostgreSQL database works best if you use their respective "dump" programs to create a plain-text version of the database. I posted a script for MySQL here. If you read the code in that script, you'll see how I created date-named backup files. For directories, you could use something like:

    Code:
    TODAY=$(date +%Y%m%d)
    STALE=$(date +%Y%m%d --date='8 days ago')
    cd /path/to/backup/directory
    rmdir $STALE
    mkdir $TODAY
    cd $TODAY
    rsync -av ...
    If you ask for help, please have the courtesy to check for responses and thank the people who helped you.

    Blog · Linode System Administration Guides · Android Apps for Ubuntu Users

  5. #5
    Join Date
    Feb 2010
    Location
    QLD, Australia
    Beans
    491
    Distro
    Kubuntu 12.04 Precise Pangolin

    Re: Web Server Backups

    Quote Originally Posted by SeijiSensei View Post
    Backing up a MySQL or PostgreSQL database works best if you use their respective "dump" programs to create a plain-text version of the database. I posted a script for MySQL here. If you read the code in that script, you'll see how I created date-named backup files. For directories, you could use something like:

    Code:
    TODAY=$(date +%Y%m%d)
    STALE=$(date +%Y%m%d --date='8 days ago')
    cd /path/to/backup/directory
    rmdir $STALE
    mkdir $TODAY
    cd $TODAY
    rsync -av ...
    Thank you, I'm familiar with creating dirs in that method, though what I want to know is it possible to have rsync only copy the new and updated files into that days folder? Wont that create a full copy in to the TODAY folder?
    I'd like to try and save space and only copy the files that are new or modified since the first rsync.
    Something like this;

    /backups/20130301/
    File-One
    File-Two
    File-Three
    File-Four
    File-Five

    /backups/20130302/
    File-Four

    /backups/20130303/
    File-Three
    File-Five

    Does this make sense? Is this possible or will rsync only do a full copy if it's into a new dir?
    Ubuntu 12.04
    “To mess up a Linux box, you need to work at it; to mess up your Windows
    box, you just need to work on it”.
    TrinhamTechnologies.com.au

  6. #6
    Join Date
    Oct 2009
    Beans
    Hidden!
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Web Server Backups

    Quote Originally Posted by SeijiSensei View Post
    I use rsync to transfer the web directories to an offsite machine, and a script that runs pg_dump to back up my PostgreSQL databases to text files. I then suck those over with rsync as well.

    Tar is fine, but you need to untar to archive if you want to restore a specific file.

    If you want to have rotations, then you'd need to write a script that creates a new directory each day and copies that day's snapshot to the backup server with rsync.
    Seconding this as it is what I use (or used) when my site was getting updated frequently.

    I have used cp -al and rsync -ai to create incremental backups of my files on my server. I don't see why that couldn't work for a web server.

    EDIT: Thanks for posting the date +%Y%m%d --date='8 days ago' command. I didn't know date could do that and it'll save me from going thru my backups and deleting stuff that is older than 6 months.
    Last edited by CharlesA; March 16th, 2013 at 06:08 AM.
    Come to #ubuntuforums! We have cookies! | Basic Ubuntu Security Guide

    Tomorrow's an illusion and yesterday's a dream, today is a solution...

  7. #7
    Join Date
    Nov 2008
    Location
    Metro Boston
    Beans
    9,001
    Distro
    Kubuntu 14.04 Trusty Tahr

    Re: Web Server Backups

    Quote Originally Posted by Jonny87 View Post
    Thank you, I'm familiar with creating dirs in that method, though what I want to know is it possible to have rsync only copy the new and updated files into that days folder? Wont that create a full copy in to the TODAY folder?
    No, as the name says it's designed to synchronize two directory trees. If you want to do incremental backups, one possibility is to identify each day's files with the "find" command using the "-anewer" option to identify files more recent than a baseline file. I used this in the past where I'd write a tarball each night based on identifying files newer than the previous night's tarball. See "man find" for more details.

    Quote Originally Posted by CharlesA View Post
    EDIT: Thanks for posting the date +%Y%m%d --date='8 days ago' command. I didn't know date could do that and it'll save me from going thru my backups and deleting stuff that is older than 6 months.
    The --date option is remarkably flexible and is able to parse all sorts of human-readable date specifications like "days ago".
    Last edited by SeijiSensei; March 16th, 2013 at 09:46 PM.
    If you ask for help, please have the courtesy to check for responses and thank the people who helped you.

    Blog · Linode System Administration Guides · Android Apps for Ubuntu Users

  8. #8
    Join Date
    Jan 2010
    Location
    Germany
    Beans
    165
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Web Server Backups

    I know this is probably a late for a reply, I always use bacula. Some may say its a bit of an over kill but if you spend the time to figure how to configure it then it will serve you well. For MySQL dumps I wrote my own script when I let the crontab take care of. So at least for MySQL I have 30 days worth of backups to use just in case.

    There are literally tonnes of options for backing up a server/web server and mostly its personal preference, depending on how much time you want to invest in the configuration.

    For my web server, mainly because the content is so valuable, I backup to an external device and an offsite cloud just in case. The main server backup just sits on an external device. Plus of course because I run everything inside ESXi I have all my VMs backup anyway to a Flash drive.
    Try not to be a man of success but be a man of value
    USE FUL LINKS
    Ubuntu Server setup guide
    setting up a DNS Server on Ubuntu

  9. #9
    Join Date
    Feb 2010
    Location
    QLD, Australia
    Beans
    491
    Distro
    Kubuntu 12.04 Precise Pangolin

    Re: Web Server Backups

    Thanks every one for your input.

    If I use tar, do i need to have a script to do the MYSQL dumps a some have said they do? or will tar still backup the MYSQL side of things fine?

    This my current plan;

    / >> Root.tar
    /home >> Home.tar
    Create a uncompressed tar of / and /home have it updated on a daily bases. This keeps an up to date backup that can be easily and quickly restored. Also allowing single file extraction.
    Or possibly rsync for this stage.

    Root.tar >> /Archives/Root/$DATE.tar.bz2
    Home.tar >> /Archives/Home/$DATE.tar.bz2
    After the updates are complete, then create a compressed copy of the updated tar so that there is a backup for each day. Will also look at using date to remove older archives as suggested above.

    I don't suppose anyone knows how to use that date option to create a pattern of something like,
    Keep all for the last 7 days,
    Keep one per week for the last 4 weeks,
    Keep one per month for the last 24 months,
    Keep one per years for all years.
    This would give my friend some flexibility to back date to almost any point in time if needed. This ofcourse will all depend on how much space he wants to dedicate to Backups.

    What are peoples thoughts on this? I have plenty of experience writing tar backup scripts for my own personal computers, but not for a web server, looking for advice from those with experience in this field.
    Last edited by Jonny87; March 17th, 2013 at 04:36 AM.
    Ubuntu 12.04
    “To mess up a Linux box, you need to work at it; to mess up your Windows
    box, you just need to work on it”.
    TrinhamTechnologies.com.au

  10. #10
    Join Date
    Jan 2010
    Location
    Germany
    Beans
    165
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Web Server Backups

    Hi,

    The things that you are asking for with date labelled backup scripts etc are fairly easy to do with a simple bash script. I wrote one for my own use but it can be adapted within any buntu environment. I'm living in Germany and I'm yet to sleep so if you can wait ill send you a link to the script I wrote to carry out this task. Btw you will also need to have a crontab script too but I'll bundle that for you too. Hope that helps

Page 1 of 3 123 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •