Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 28

Thread: Web Server Backups

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

    Re: Web Server Backups

    Thanks, that would be real handy. Year I was already aware that it will need to be setup in crontab. Waiting for my mate to get back to me on final details though i.e location of backup server share, How often he wants it to run, how many he wants to keep etc.

    He wants to set it up around the end of the month sometime but I'm just getting the script ready now so I can just upload it and set it to run.

    It's is server and his web hosting company, I'm just his Linux "Expert" Consultant/Assistant as he doesn't really know Linux and I do. I've already helped him migrate the server form the Windows to Linux as he was having issues with Apache on Windows. Its been fine since the migration. And recently I've been pushing him to make sure he gets a backup system in place, I offered to set up a script if he wanted.
    He hosts my site for free so I work for him in return.
    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. #12
    Join Date
    Nov 2008
    Location
    Metro Boston
    Beans
    8,754
    Distro
    Kubuntu 14.04 Trusty Tahr

    Re: Web Server Backups

    If you want to preserve a backup, just do a test of the day of the week or month and skip the deletion step if it matches the criterion. For instance

    Code:
    if [ "$(date +%w)" != "0" ]
    then
        rm -f /path/to/backups/somefile.tgz
    fi
    That skips the deletion on Sundays when "date %w" returns zero.
    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. #13
    Join Date
    Feb 2010
    Location
    QLD, Australia
    Beans
    479
    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 ...
    OK, so with;
    Code:
    STALE=$(date +%Y%m%d --date='8 days ago')
    could that be applied with months or years, i.e.
    Code:
    STALE=$(date +%Y%m%d --date='8 months ago')
    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

  4. #14
    Join Date
    Nov 2008
    Location
    Metro Boston
    Beans
    8,754
    Distro
    Kubuntu 14.04 Trusty Tahr

    Re: Web Server Backups

    Yes. From the "man" page for date:
    The --date=STRING is a mostly free format human readable date string such as "Sun, 29 Feb 2004 16:21:42 -0800" or "2004-02-29 16:21:42" or even "next Thursday". A date string may contain items indicating calendar date, time of day, time zone, day of week, relative time, relative date, and numbers. An empty string indicates the beginning of the day. The date string format is more complex than is easily documented here but is fully described in the info documentation.
    Might I suggest experimentation as a method for answering questions like this?
    Code:
    $ date --date='8 months ago'
    Tue Jul 17 09:17:11 EDT 2012
    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. #15
    Join Date
    Oct 2009
    Beans
    Hidden!
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Web Server Backups

    Quote Originally Posted by SeijiSensei View Post
    Yes. From the "man" page for date:


    Might I suggest experimentation as a method for answering questions like this?
    Code:
    $ date --date='8 months ago'
    Tue Jul 17 09:17:11 EDT 2012
    +1. I did that as soon as I saw you could mess with the date like that.
    Come to #ubuntuforums! We have cookies! | Basic Ubuntu Security Guide

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

  6. #16
    Join Date
    Feb 2010
    Location
    QLD, Australia
    Beans
    479
    Distro
    Kubuntu 12.04 Precise Pangolin

    Re: Web Server Backups

    Quote Originally Posted by SeijiSensei View Post
    Yes. From the "man" page for date:


    Might I suggest experimentation as a method for answering questions like this?
    Code:
    $ date --date='8 months ago'
    Tue Jul 17 09:17:11 EDT 2012
    Yes sorry I should have thought to experiment around with it like that.
    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

  7. #17
    Join Date
    Feb 2010
    Location
    QLD, Australia
    Beans
    479
    Distro
    Kubuntu 12.04 Precise Pangolin

    Re: Web Server Backups

    So this is what I have so far, I'm yet to get the full address of backup location from my friend so I have it represented by * for the time being.

    Code:
    #! /bin/sh
    
    ## Things to do first
    ##    mkdir */RootAchives
    ##    mkdir */HomeAchives
    ##    mkdir */Logs
    ##    mkdir */Logs/Root
    ##    mkdir */Logs/Home
    
    
    #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    # VARIABLE PATHS
    
    
    DATE="`date +%d/%m/%Y`"
    ROOT="**/UpdatingRootBackup"
    HOME="**/UpdatingHomeBackup"
    ROOT_ARCH="**/RootAchives/$DATE"
    HOME_ARCH="**/HomeAchives/$DATE"
    SRC_ROOT="/"
    SRC_HOME="/home"
    LAST_ROOT="**/LastRootUpdate"
    LAST_HOME="**/LastHomeUpdate"
    ROOT_LOGS="**/Logs/Root/$DATE.txt"
    HOME_LOGS="**/Logs/Home/$DATE.txt"
    STALE=$(date +%Y%m%d --date='8 days ago')
    
    
    #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    
    
    #======================================================================================================
    # ROOT
    #Change Backup Dir Name.
    mv $LAST_ROOT $ROOT 
    
    
    #Back up the root drive.
    rsync -rtpogvuzs --progress --delete --exclude=/proc --exclude=/lost+found --exclude=/mnt --exclude=/sys --exclude=/home --exclude=/media $SRC_ROOT $ROOT | cat > $ROOT_LOGS 
    
    
    #Archive the Root Update.
    tar -cvpjf  $ROOT_ARCH $ROOT
    
    
    #Change Update Dir Name
    mv $ROOT $LAST_ROOT
    
    
    #======================================================================================================
    # HOME
    
    
    #Change Backup Dir Name.
    mv $LAST_HOME $HOME 
    
    
    #Back up the home drive
    rsync -rtpogvuzs --progress --delete  $SRC_HOME $HOME | cat > $HOME_LOGS
    
    
    #Archive the Root Update.
    tar -cvpjf  $HOME_ARCH $HOME
    
    
    #Change Update Dir Name
    mv $HOME $LAST_HOME
    
    
    #======================================================================================================
    # Remove Old Backups
    
    
    rm **/RootArchives/$STALE
    rm **/HomeAchives/$STALE
    Can any one see anything wrong with this backup process? Does anyone have any further suggestions?
    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

  8. #18
    Join Date
    Nov 2007
    Location
    Newry, Northern Ireland
    Beans
    1,258

    Re: Web Server Backups

    You might also look at rdiff-backup, it uses rsync but allows incremental backups and restore from a point in time.
    Can't think of anything profound or witty.
    My Blog: http://gonzothegeek.blogspot.co.uk/

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

    Re: Web Server Backups

    Yea I had thought about that. I might still go with that.
    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. #20
    Join Date
    Feb 2006
    Beans
    27

    Re: Web Server Backups

    I use and recommended http://www.rsnapshot.org/ . rsnapshot is a complete rsync backup solution and i very easy to restore

Page 2 of 3 FirstFirst 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
  •