mailbash script for a FTP dump of the newly create relax wiki


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by Troels Emtekær Linnet on July 17, 2013 - 13:25:
Dear relax developers and users.

I hereby send a bash script for a FTP dump of the newly create relax wiki.
Thereby the wiki can easily be created anywhere else, if created
together with the mysql database.

To prevent abuse of the webpage hosting service, I need to keep the
password secret.

The password is shared with Edward d'Auvergne.

I suggest a setup, where Edward run a cronjob a his infrastructure,
and expose the files to:
http://download.gna.org/relax/wiki/ftpdump

The FTP dump should only tricker when new files are added.
That would normally only be when images are uploaded.

Best
Troels Linnet

-----------------------
#!/bin/bash
# -*- coding: UTF-8 -*-
# Script for dumping ftp server automatically using cron.

# exec test
exec_test () {
[ $? -eq 0 ] && echo "-- Command successfully executed" || echo "--
Command failed; exit 1"
}

# Filenames
dbhost="web3.gigahost.dk"
# The following two fields are kept secret, to prevent abuse.
# Please contact Troels Linnet at: tlinnet _at_ gmail dot com, for access.
dbuser="secret"
dbpwd="secret"

mydate=`date '+%Y%m%d_%H%M'`
mytime=`date '+%T %Y%m%d'`
backupfolder="${HOME}/backup/ftpdump"
backupfoldermirror="${backupfolder}/mirror"
backupfoldercurrent="${backupfolder}/current"
mkdir -p $backupfolder $backupfoldermirror $backupfoldercurrent

# Logging
exec 3>&1 4>&2
trap 'exec 2>&4 1>&3' 0 1 2 3
exec 1>>${backupfolder}/ftpdump.log 2>&1
# Everything below will go to the log file

dump_base () {
echo "###########################"
echo "STARTING on: $mytime"
echo "Mirror syncing..."
cd $backupfoldermirror
lftp -e "open ftp://${dbuser}:${dbpwd}@${dbhost} && mirror --no-perms
--exclude-glob backup_scripts/ --exclude-glob cache/ --exclude-glob
LocalSettings.php --parallel=10 && bye"
}

compress_base () {
echo "Compressing current..."
DIFF=`diff -q -r $backupfoldermirror $backupfoldercurrent`
echo -e "Difference between sync and current is:\n$DIFF"
DIFFARR=($DIFF)
LENDIFFARR=${#DIFFARR[@]}
if [ "$LENDIFFARR" -gt "0" ]
then
rm -rf $backupfoldercurrent
cp -p -r $backupfoldermirror $backupfoldercurrent
tar -zcf ${backupfolder}/ftpdump_${mydate}.tar.gz $backupfoldercurrent/
fi
}

dump_base ; exec_test
compress_base ; exec_test

echo "Done, quit!"



Related Messages


Powered by MHonArc, Updated Fri Jul 19 09:20:08 2013