Wanted - Cron-Job SQL/PHP Server guru |
Wanted - Cron-Job SQL/PHP Server guru |
Nov 7 2008, 02:00 PM
Post
#1
|
|
Founder Group: Chairman Posts: 14434 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 Cheers Doug |
|
|
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!
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! |
|
|
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. |
|
|
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 |
|
|
Nov 21 2008, 05:55 PM
Post
#5
|
|
Member Group: Admin Posts: 976 Joined: 29-September 06 From: Pasadena, CA - USA Member No.: 1200 |
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 On my server at home and on my workstation at work I use gtar instead of zip but the principle is the same. I do linear backups on Sundays and an incremental backup every day. Some suggestions: - consider iso9660 files. If you want to retrieve one file or a handful it makes it easier to just fetch single isolated files. I prefer tarballs since even if they get corrupted you can still recover some files out of them. - consider file system/ssh/rsync file size limits - whatever you do, periodically check your backups, try to unpack them and see if you are missing something. - if you are going to provide the hardware (disks) to do the backup, NEVER EVER use the same brand for your main disks and your backup disks (*). Purchase different brands and at different dates so that their wear and tear is different. Paolo -------------------- Disclaimer: all opinions, ideas and information included here are my own,and should not be intended to represent opinion or policy of my employer.
|
|
|
Lo-Fi Version | Time is now: 22nd September 2024 - 09:21 PM |
RULES AND GUIDELINES Please read the Forum Rules and Guidelines before posting. IMAGE 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. |