Activity Stream
48,167 MEMBERS
62370 ONLINE
besthostingforums On YouTube Subscribe to our Newsletter besthostingforums On Twitter besthostingforums On Facebook besthostingforums On facebook groups

Results 1 to 10 of 10
  1.     
    #1
    ψ(`∇?)ψ

    Default Fully automated backup - SSH to Windows FTP

    Introduction:

    What we need, to make this thing working is:

    root access via ssh, to our web server, where our site(s) is(are) - for this, we can use putty, for example.
    Windows based system (another server or home PC)
    Windows 2008, 2003, or windows XP/7/Vista
    WinSCP (download link provided in manual)

    We also need a basic knowledge about ssh and of course, to install a simple program like WinSCP
    Manual is really simple and straight forward, with all necessary links included, it is made by n00b, for n00bs

    Part 1 - Making automated backup of wordpress blog


    Open shh, login, and for the sake of example, lets say you have complete root access, and your folder is:

    /home/admin/


    inside of that folder, there could be your wordpress website, named
    /home/admin/blabla (just example)

    Don't go in your "blabla" folder
    create folder named backup in home/admin/ with command:

    Code: 
    mkdir backup
    so you get /home/admin/backup/

    And make a folder, where you will keep your script, that will backup things for you

    Code: 
    mkdir scripts
    Enter that folder with command:

    Code: 
    cd scripts
    And you got /home/admin/scripts

    Time to make a backup script

    type this into your cmd line:

    Code: 
    vi blabla.script
    Text editor will open up, press " i " on your keyboard, to enter edit mode, now your screen looks something like this:



    you are sure you did all good, if on the bottom it says INSERT


    Now, you can copy this piece of script in notepad, on your home desktop, open your wp-config.php, from your wordpress website, to see necessary details, in case you don't already have them somewhere, like on the image:




    and enter them properly, only bold parts are the ones you need to replace

    Code: 
    #!/bin/bash
    MYSQL_USERNAME=sqlusername
    MYSQL_PASSWORD=password
    MYSQL_DATABASE=sqldatabasename
    SITE_DIR=/home/admin/blabla
    BACKUP_DIR=/home/admin/backup/
    BACKUP_NAME=yoursite-$(date +%Y%m%d-%H%M)
    TMP_DIR=/home/admin/backup/$BACKUP_NAME
    DB_BACKUP=yourwebsite-db.sql
    
    mkdir --parents "$TMP_DIR" || { echo "ERROR: Could not create temp directory"; exit 1; }
    cd "$TMP_DIR" || { echo "ERROR: Could not create temp directory"; exit 1; }
    mysqldump -u $MYSQL_USERNAME --password=$MYSQL_PASSWORD $MYSQL_DATABASE > "$DB_BACKUP" || { echo "ERROR: Could not backup mysql db"; exit 1; }
    mkdir site || { echo "ERROR: Could not create temp site directory"; exit 1; }
    cp -R "$SITE_DIR" site || { echo "ERROR: Could not backup web site"; exit 1; }
    tar czf "$BACKUP_DIR$BACKUP_NAME.tar.gz" * || { echo "ERROR: Could not create backup archive"; exit 1; }
    rm -rf "$TMP_DIR" || { echo "ERROR: Could not clean up temp directory";  }
    you can copy paste finished script in ssh, in the way that you wll normally select text in notepad, CTRL+C, and to paste it to ssh, press right mouse button.

    Now we need to save it.

    Press ESC on your keyboard.
    Type:

    Code: 
    :write
    and hit enter
    now we need to exit from here
    Code: 
    :quit
    and hit enter


    Now we prepared a script that will backup our website, together with complete SQL database.

    We need to make it more automatic

    We want CRON job to run it at certain point of time, to make a backup, for example, when our site is least busy (which we previously investigated, when our website have least visitors)

    to make it run on cron, type:

    Code: 
    crontab -e
    and again text editor will open up, then press INSERT
    If there is something already, leave it there, just add your line:

    Code: 
    15 3 * * * /home/scripts/blabla.script

    This option will run our backup script at 3:15 AM server time, every day

    To see more options, how to setup cron, with your own preferences, check here:

    Code: 
    http://adminschoice.com/crontab-quick-reference
    Part 2 - Auto-download backup to windows based system

    Ok, now we have this semi-automated...having backup on server where website is, isn't much helpful, in case when sky is falling on you.
    So, now what we need is program named WinSCP, which can be downloaded here:

    Code: 
    http://winscp.net/eng/download.php
    Download Installation package, and install it.

    Open WinSCP, so you can enter your FTP (sFTP) details, and save them:



    Save a session as something like root@mywebsite

    Login to your ftp, just to see that you typed all properly.

    You can close WinSCP now.

    For example, in your C: drive, create folder named websitebackup to get C:\websitebackup <--this is where we will store our website backup (dooh)

    By default, WinSCP is installed in "C:\Program Files (x86)\WinSCP\"

    Move in that folder, and create a text file, named backup.txt

    Right click mouse in that folder, you will get popup menu, go to New, then to Text Document



    Open your newly created text file and copy paste, and change if necessary:

    Code: 
    option batch on
    option confirm off
    open root@mywebsite  // change this, in case you named your login profile in something different
    cd /home/admin/backup  //also change this, in case this is not your backup folder on your web server
    get -delete * "c:\websitebackup\"
    exit
    Save your backup.txt file in your WinSCP folder

    We are almost done, just to automate windows to collect our backup now.

    Go to Start > All Programs > Administrative Tools > Task Sheduler



    On Right menu, click on Create Basic task

    New window will pop up, name it, and give it some description:

    Name: WinSCP
    Description: downloading backup

    Click Next, and you are in new menu, since we are creating new backup each day, it would be a good idea to synchronize webserver with backup, so, go with Daily option in menu, and hit Next

    Define a proper time ( take care of timezones on both servers, if you 've put crontab to run on 3:15 on webserver, make a backup 10 minutes later, adding time 3:25)

    Hit Next

    Leave Action on default, as Start a program

    Next again

    Add full path to your WinSCP executable file, for example:

    "C:\Program Files (x86)\WinSCP\WinSCP.exe"

    In argument field, add this piece:

    /console /script=backup.txt

    And in field Start in:

    C:\Program Files (x86)\WinSCP\

    Hit Finish (or next)

    Part 3 - We're done!

    And, sha-zaaam, at 3:15, your webserver will make a full backup of your wordpress blog, and at 3:25, your windows server (home PC), will start downloading your backup trough FTP (only in case power is turned on )

    So, here you go...enjoy

    Magic of automation
    cvrle77 Reviewed by cvrle77 on . Fully automated backup - SSH to Windows FTP Introduction: What we need, to make this thing working is: root access via ssh, to our web server, where our site(s) is(are) - for this, we can use putty, for example. Windows based system (another server or home PC) Windows 2008, 2003, or windows XP/7/Vista WinSCP (download link provided in manual) We also need a basic knowledge about ssh and of course, to install a simple program like WinSCP Rating: 5


  2.   Sponsored Links

  3.     
    #2
    Banned
    Thanks for this

  4.     
    #3
    Member
    Website's:
    eih.bz pornDDL.me sexytattoochicks.tumblr.com
    Awesome

    Can I post it on platinumW?

  5.     
    #4
    mmm mmm!
    Thanks for sharing.
    HATERS GONNA probably bring up some valid points considering I am an ignorant little twat so far up my own ass that i blame my problems on everyone and if you criticize me you're automatically wrong.

  6.     
    #5
    Member
    Website's:
    Elite.SO Defendos.com Motionite.com
    Yes you can, as long as you link back and give credits.

    Defendos BETA3 Released! Thread - Official Website

  7.     
    #6
    ψ(`∇?)ψ
    Quote Originally Posted by pi0tr3k View Post
    Awesome

    Can I post it on platinumW?
    Ofc you can, as l0cal said,

    Any web host, that wants to share this, with their users, and give them this manual, can do the same thing. Give credits, and link back to this article.


  8.     
    #7
    Member
    Website's:
    eih.bz pornDDL.me sexytattoochicks.tumblr.com
    OFC I was going to give credits, I'm not a leecher

  9.     
    #8
    Member
    Website's:
    iFunMaza.com
    Awesome! TFS

    FB - http://www.facebook.com/IfunMaza
    Twitter - twitter.com/#!/iFunMaza

  10.     
    #9
    Member
    Website's:
    csoffensive.com fagbag.me
    nice one

  11.     
    #10
    ψ(`∇?)ψ
    Quote Originally Posted by pi0tr3k View Post
    OFC I was going to give credits, I'm not a leecher
    Never said you are, backlink is for KWWH, not me...


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. FireHacking - Fully Automated Script
    By Faizann20 in forum Completed Transactions
    Replies: 5
    Last Post: 1st Jul 2012, 02:19 AM
  2. Sceneflux - Fully automated DDL
    By Daniel in forum Useful Sites
    Replies: 29
    Last Post: 15th Dec 2011, 08:16 AM
  3. Automated DB backup and FTP
    By Time in forum Technical Help Desk Support
    Replies: 9
    Last Post: 10th May 2011, 05:05 PM
  4. Ultimate RDP Tool v1.1 - Fully Automated! + MTN!
    By l0calh0st in forum Webmaster Resources
    Replies: 36
    Last Post: 11th Oct 2010, 12:24 AM
  5. [Shared] Fully Automated Rapidleech For first time
    By mRAza in forum Archive
    Replies: 80
    Last Post: 20th May 2010, 12:27 AM

Tags for this Thread

BE SOCIAL