Bering-uClibc 6.x - User Guide - Advanced Topics - Setting Up Backup to Remote Server
Advanced Topics - Setting Up Backup to Remote Server | ||
---|---|---|
Prev | Bering-uClibc 6.x - User Guide | Next |
Contents
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
The backup.lrp
Package provides a backup script and a cron script (/etc/cron.weekly/backup
)
Add the tftpd and backup Package to the LRP line 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"
Save the file and exit the 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 |