SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Hybrid View

  1. #1
    SitePoint Evangelist
    Join Date
    Mar 2011
    Location
    Bellingham, WA
    Posts
    450
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Automatic local download of Files for Backup

    Hello!

    I'm running a nightly CRON job to back up by database just in case somebody gets into it and decides to have some fun. In addition, I've got a local copy of my site. However, there are a few dynamically user created folders that I'd also like to backup just in case somebody wreaks havoc on my site. Is there any easy way to set up some sort of automatic local back-up that "gets" a set of folders, the folder structure, and the files, aka the way that I could do it non-automatically through Dreamweaver?

    Thank you,

    Eric

    PS I don't want to abuse this forum, so just FYI I posted a similar post in the PHP forum hoping to get a PHP solution. Since nobody has responded there, my guess is that a PHP solution would be pretty involved. However, please feel free to delete if it isn't appropriate to ask this in the more general setting!

  2. #2
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Well if you have SSH access you could setup a routine to TAR and GZIP the whole website directory, via a task scheduler. May be possible to do this via local system that would SSH into the server and then use FTP via SSH to download the TAR.GZ file. However, I'm unaware of how to do this at the moment.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  3. #3
    SitePoint Evangelist
    Join Date
    Mar 2011
    Location
    Bellingham, WA
    Posts
    450
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the info!

    Am I being a little crazy to want to do this? I mean....my provider backs things up as well, I'm assuming....

  4. #4
    SitePoint Member
    Join Date
    Mar 2011
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey, yes, you can do this, depending on how much access you have to the server, and then what resources you have to backup to. Here is a system I have just setup.

    Webserver (where I have root) > readyNAS local storage (in my home)

    • Install the root plugin on the readyNAS, allowing root to ssh into.
    • Open firewall on home router to ONLY allow external access from Webserver IP
    • Get Webserver public key text, in /root/.ssh/
    • Copy this text to /root/.ssh/authorized_keys on readyNAS


    Now Webserver can SSH into readyNAS without having to login, just using the public key. Next, create a shell (or PHP or whatever) script to backup all the files you want i.e

    • Turn off services, like apache2, mysqld
    • rsync backup the mysql folder + config files
    • rsync backup the apache config folder
    • rsync backup anything else of note
    • Turn on services to resume normal server operation


    The rsync is from my webserver, to the readyNAS. I use -a for archive mode, so its compressed, and incremental. I use a php script, run daily with CRON to define the root backup folder, using days of week. So we have a 7 day rolling incremental backup.

    This is a pretty secure system i.e. ssh between to servers, with access on the target only allowed to one specific IP. Even better, the script could be designed to run repeatedly to different targets, giving you multiple backups at remote locations, if required.

    In our case, we also use the same script, using rsync to backup files to another local disk on the Webserver. This time, not using days of week, but just a daily backup.

    The key info to google for here i.s

    • firewall, port forwarding and limit IP access
    • setup ssh between servers via public .pub keys
    • how to use rsync
    • how to use cron


    Why so paranoid? Well, we've just had two complete server failures on two different hosts. And this took us two weeks to recover from overall. So, backup like this really is a necessity....

    Hope this helps

  5. #5
    SitePoint Evangelist
    Join Date
    Mar 2011
    Location
    Bellingham, WA
    Posts
    450
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Thanks for such a completed response!


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
  •