Difference between revisions of "Bering-uClibc 4.x - User Guide - Advanced Topics - Setting Up Backup to Remote Server"

From bering-uClibc
Jump to: navigation, search
m (Navigation link tidyups)
m (navigation)
 
Line 4: Line 4:
 
| width="20%" align="left"  | [[Bering-uClibc 4.x - User Guide - Advanced Topics - Setting Up Remote Monitoring|Prev]]
 
| width="20%" align="left"  | [[Bering-uClibc 4.x - User Guide - Advanced Topics - Setting Up Remote Monitoring|Prev]]
 
! width="60%" align="center" | [[Bering-uClibc 4.x - User Guide]]
 
! width="60%" align="center" | [[Bering-uClibc 4.x - User Guide]]
| width="20%" align="right"  | [[Bering-uClibc 4.x - User Guide - Advanced Topics - Modifying initrd.lrp|Next]]
+
| width="20%" align="right"  | [[Bering-uClibc 4.x - User Guide - Advanced Topics - Setting up a HTTP Anti Virus Proxy|Next]]
 
|}
 
|}
 
----
 
----
Line 85: Line 85:
 
| width="40%" align="left"  | [[Bering-uClibc 4.x - User Guide - Advanced Topics - Setting Up Remote Monitoring|Prev]]
 
| width="40%" align="left"  | [[Bering-uClibc 4.x - User Guide - Advanced Topics - Setting Up Remote Monitoring|Prev]]
 
| width="20%" align="center" | [[Bering-uClibc 4.x - User Guide - Advanced Topics|Up]]
 
| width="20%" align="center" | [[Bering-uClibc 4.x - User Guide - Advanced Topics|Up]]
| width="40%" align="right"  | [[Bering-uClibc 4.x - User Guide - Advanced Topics - Modifying initrd.lrp|Next]]
+
| width="40%" align="right"  | [[Bering-uClibc 4.x - User Guide - Advanced Topics - Setting Up a HTTP Anti Virus Proxy|Next]]
 
|}
 
|}
  
 
[[Category:Bering-uClibc 4.x]]
 
[[Category:Bering-uClibc 4.x]]
 
[[Category:User Guide]]
 
[[Category:User Guide]]

Latest revision as of 17:01, 30 October 2011

Advanced Topics - Setting Up Backup to Remote Server
Prev Bering-uClibc 4.x - User Guide Next


Objectives

We assume here that you want to configure automatic backup to remote server.

Backup mechanism is simple and doesn't require specific software. Here is order of operations:

  • LEAF box mounts storage and runs tftp server on mountpoint, after - it sends HTTP request to backup server with list of files
  • Backup server fetches files from list, and sends answer to LEAF box
  • LEAF box stops tftp server and umounts storage

Step 1: Configure Remote Server

You need a remote server with next available software:

  • HTTP server
  • tftp client
  • CGI backup script

Here is sample backup script (it uses atftp as ftp client):

#!/bin/bash

# Path to dir where files will be stored
REPO="/var/lib/backup"

if [ -n "$HTTP_USER_AGENT" ]; then
    echo "Content-Type: text/html"
    echo
fi

if [ -n "`echo $HTTP_USER_AGENT | grep "Wget"`" ] && [ -n "$REMOTE_ADDR" ]; then
    if [ "$REQUEST_METHOD" = "POST" ] ; then
        _F_QUERY_STRING=`dd count=$CONTENT_LENGTH bs=1 2> /dev/null`
        if [ "$QUERY_STRING" != "" ] ; then
            _F_QUERY_STRING="$_F_QUERY_STRING""&$QUERY_STRING"
        fi
    else
        _F_QUERY_STRING="$QUERY_STRING"
    fi
    filelist="${_F_QUERY_STRING//\+/ }"
    # Create directory for backup in format <IP>/<date>
    mkdir -p $REPO/$REMOTE_ADDR/`date +%Y%m%d`
    cd $REPO/$REMOTE_ADDR/`date +%Y%m%d`
    # Generate commands for tftp client
    scmd="binary\n"
    for i in $filelist; do
        rm -f $i
        scmd=$scmd"get $i\n"
    done;
    # Call tftp client
    echo -e "$scmd"|atftp $REMOTE_ADDR 2>&1 &>/dev/null
    # Return result of tftp client execution to LEAF
    echo $?
fi


Step 2: Declare the backup.lrp and tftpd.lrp Package

backup.lrp package has backup script and cron script (/etc/cron.weekly/backup)

Add the tftpd and backup Package to the LRP list in leaf.cfg as described in the LEAF Packages Chapter.

Step 3: Configure the backup system

Invoke lrcfg and choose 3) Packages configuration, then backup and then /etc/backup.conf.

Modify string:

MIRROR="http://your.server/path.to.script"

Then - save file and exit from editor.

Step 4: Check if the backup system is working properly

To check if backup functioning properly, run /etc/cron.weekly/backup.

If all is OK, you should see in /var/log/backup.log string like

Mon Jun 20 12:14:42 EEST 2011: Backup successful



Prev Up Next