IPB

Welcome Guest ( Log In | Register )

Wanted - Cron-Job SQL/PHP Server guru
djellison
post Nov 7 2008, 02:00 PM
Post #1


Founder
****

Group: Chairman
Posts: 14431
Joined: 8-February 04
Member No.: 1



Amoungst our troops there must be someone who knows how to write Cron-jobs.

I'd like to set up the UMSF server to automate backups of the forum DB and attachments folder, but it's just a bit beyond me. It's a LAMP setup using Cpanel 11.

Anyone who has 'the knowledge' to help me out - let me know!

No pay, but you can have an UMSF subdomain to put stuff on ( like Mike has for MMB anims ) as a UMSF perk biggrin.gif

Cheers

Doug
Go to the top of the page
 
+Quote Post
 
Start new topic
Replies
imipak
post Nov 7 2008, 05:27 PM
Post #2


Member
***

Group: Members
Posts: 646
Joined: 23-December 05
From: Forest of Dean
Member No.: 617



Hi there! smile.gif

If it's a simple file copy (or compress, copy file off box, delete local copy) that'd be pretty trivial to do. PHP's probably not the ideal language to write the script in though, a tiny shell script is probably the best way to do it.


--------------------
--
Viva software libre!
Go to the top of the page
 
+Quote Post
Fran Ontanaya
post Nov 7 2008, 07:24 PM
Post #3


Member
***

Group: Members
Posts: 293
Joined: 22-September 08
From: Spain
Member No.: 4350



As imipak says, if it's just about copying files it's quite simple. I use a bash script to copy, zip, encrypt and upload my docs to an external server. For a five times per month backup, a simple script could look like this:

#!/bin/bash
THEDAY=`date +%d`
THEDATE=`date +%m-%d`
if [ $THEDAY = 01 -o $THEDAY = 7 -o $THEDAY = 13 -o $THEDAY = 19 -o $THEDAY = 25 ] ;
then
zip -r ~/backups/backup-mydocs-$THEDATE.zip ~/folder/mydocs/
fi
echo 'Backup finished. Closing...'
sleep 2

That zips everything in the folder '~/folder/mydocs/'. The old backups get overwritten after a year.

You can edit the cron with "crontab -e". I do my backups at 20:16 because I know the computer is on at that time. The line would look like this:

16 20 * * * ~/backups/backup.sh >/dev/null 2>&1 # Backup,

---

Or you can use a script like this:

#!/bin/bash
THEDATE=`date +%m-%d`
zip -r ~/backups/backup-mydocs-$THEDATE.zip ~/folder/mydocs/
echo 'Backup finished. Closing...'
sleep 2

And a cron like this, for the same effect:

16 20 1 * * ~/backups/backup.sh >/dev/null 2>&1 # Backup,
16 20 7 * * ~/backups/backup.sh >/dev/null 2>&1 # Backup,
16 20 13 * * ~/backups/backup.sh >/dev/null 2>&1 # Backup,
16 20 19 * * ~/backups/backup.sh >/dev/null 2>&1 # Backup,
16 20 26 * * ~/backups/backup.sh >/dev/null 2>&1 # Backup,

PS. I decline the subdomain offer.
Go to the top of the page
 
+Quote Post
Fran Ontanaya
post Nov 7 2008, 07:42 PM
Post #4


Member
***

Group: Members
Posts: 293
Joined: 22-September 08
From: Spain
Member No.: 4350



Same script with FTP. It deletes the local copy after:

#!/bin/bash
HOST='xxxx.xxxxxx.com'
USER='xxxxxx'
PASSWD='xxxxxx'
THEDATE=`date +%m-%d`
zip -r ~/backups/backup-mydocs-$THEDATE.zip ~/mydocs/
ftp -v -n $HOST <<**
user $USER $PASSWD
cd backups/mydocs/
bin
put ~/backups/backup-mydocs-$THEDATE.zip
bye
**
rm ~/backups/backup-mydocs-$THEDATE.zip
echo 'Backup finished. Closing...'
sleep 2
Go to the top of the page
 
+Quote Post

Posts in this topic


Closed TopicStart new topic

 



RSS Lo-Fi Version Time is now: 28th March 2024 - 06:08 PM
RULES AND GUIDELINES
Please read the Forum Rules and Guidelines before posting.

IMAGE COPYRIGHT
Images posted on UnmannedSpaceflight.com may be copyrighted. Do not reproduce without permission. Read here for further information on space images and copyright.

OPINIONS AND MODERATION
Opinions expressed on UnmannedSpaceflight.com are those of the individual posters and do not necessarily reflect the opinions of UnmannedSpaceflight.com or The Planetary Society. The all-volunteer UnmannedSpaceflight.com moderation team is wholly independent of The Planetary Society. The Planetary Society has no influence over decisions made by the UnmannedSpaceflight.com moderators.
SUPPORT THE FORUM
Unmannedspaceflight.com is funded by the Planetary Society. Please consider supporting our work and many other projects by donating to the Society or becoming a member.