+ Post New Thread
Results 1 to 13 of 13
*nix Thread, *nix Guru Required in Technical; Hi all, not sure if this should be here or in the scripts section but here goes. I have to ...
  1. #1
    ICTNUT's Avatar
    Join Date
    Jul 2005
    Location
    Hereford
    Posts
    1,414
    Thank Post
    193
    Thanked 247 Times in 120 Posts
    Rep Power
    61

    *nix Guru Required

    Hi all,

    not sure if this should be here or in the scripts section but here goes.

    I have to backup a linux server each night and would like to acheive the following:

    A full copy backup of the /usr/var/www/*.* folder
    A full copy backup of each mysql database on the server
    A full copy backup of the /usr/var/moodledata folder

    The contents of the above should be copied into /var/backups/[date]/ with the file structure of each remaining intact and an additional folder being created for the MySQL_DataBackup.

    Once the above has completed I need it to be FTP'd of to another server which will then be burned to DVD hopefully.

    Any pointers on where to start or if anyone has anything like this would be great.

  2. #2


    Join Date
    Feb 2007
    Location
    Northamptonshire
    Posts
    4,657
    Thank Post
    350
    Thanked 789 Times in 710 Posts
    Rep Power
    344
    Yup, give me a minute.

  3. #3

    Join Date
    Feb 2008
    Location
    UK
    Posts
    44
    Thank Post
    0
    Thanked 1 Time in 1 Post
    Rep Power
    0
    You could look into using rsync for synchronizing your "live" data with your "backup" data on another server. You can use rsync with a cronjob to automatically backup your files each night and get them transferred over to your backup server.

    Regarding your MySQL database you could either dump the database and backup the copy, sync/replicate the database or a number of other options. Sorry I don't really have any information links to hand right at this moment in time, but if any come up I'll be sure to post them.

    Best Regards,

  4. #4


    Join Date
    Feb 2007
    Location
    Northamptonshire
    Posts
    4,657
    Thank Post
    350
    Thanked 789 Times in 710 Posts
    Rep Power
    344
    Something like this should do it.

    mkdir /var/backups/`date +%Y-%m-%d%n`
    cd /var/backups/`date +%Y-%m-%d%n`

    cp -R /usr/var/www .
    cp -R /usr/var/moodledata .


    mkdir ./MySQL_DataBackup
    mysqldump -u root --password=doodah --all-databases > ./sql-`date +%Y-%m-%d%n`.sql
    gzip sql-`date +%Y-%m-%d%n`.sql

    mount -t smbfs -o username="servername\username",password=doodahpass word //servername/share /var/backups/link2backupserver

    cp -R /var/backups/`date +%Y-%m-%d%n` /var/backups/link2backupserver

  5. #5
    ICTNUT's Avatar
    Join Date
    Jul 2005
    Location
    Hereford
    Posts
    1,414
    Thank Post
    193
    Thanked 247 Times in 120 Posts
    Rep Power
    61
    @kmount:

    If i am reading your script right:

    1 - Make the backup directory
    2 - Change into the directory
    3 - Copy /usr/var/www/*.* while maintaining structure
    4 - Copy /usr/var/moodledata/*.* while maintaining structure
    5 - Make the MySQL_Backup folder
    6 - Dump the sql databases into the above folder (question to follow)
    7 - Mount to a file share with relevant permissions on a windows box
    8 - Copy the full backup folder over.

    Am i far off??

    Question regarding step 6, is this a single file dump or are they seperate for each database (i have 7 in total)

    How would you schedule this to run each night??

  6. #6


    Join Date
    Feb 2007
    Location
    Northamptonshire
    Posts
    4,657
    Thank Post
    350
    Thanked 789 Times in 710 Posts
    Rep Power
    344
    Yup, you're correct.

    If you want to do dump the backup of each database individually you can, for example.

    mysqldump -u root --password=doodah mydb1 > ./mydb1-`date +%Y-%m-%d%n`.sql
    mysqldump -u root --password=doodah mydb2 > ./mydb2-`date +%Y-%m-%d%n`.sql
    mysqldump -u root --password=doodah mydb3 > ./mydb3-`date +%Y-%m-%d%n`.sql

    The gzip line just compresses them for the sake of sanity/space.

  7. #7
    ICTNUT's Avatar
    Join Date
    Jul 2005
    Location
    Hereford
    Posts
    1,414
    Thank Post
    193
    Thanked 247 Times in 120 Posts
    Rep Power
    61
    Ahh cool that makes sense.

    What about running as a scheduled script each night, what would be the best way of doing this??

    You will have to forgive me on this as I am no *nix guru but need to have some sort of backup plan in place and seeing as this is such a key server, well I guess you understand.

  8. #8


    Join Date
    Feb 2007
    Location
    Northamptonshire
    Posts
    4,657
    Thank Post
    350
    Thanked 789 Times in 710 Posts
    Rep Power
    344
    On linux, sheduled tasks go by the name of cronjob/tabs.

    So, as root you'd need to do the following:

    Log in as root (since you're needing to grab files from everywhere, otherwise not a good idea).

    Put the content of the script into /root/doBackup.sh
    chmod it 700 so its executable by root but not readable by anyone else
    Type crontab -e which will drop you into a text editor where you put the entry below.

    30 23 * * * sh /root/doBackup.sh

    Will run it at 23:30hrs each evening.

    Have a look here for more info.

    Hope this helps.

  9. Thanks to kmount from:

    ICTNUT (25th February 2008)

  10. #9
    ICTNUT's Avatar
    Join Date
    Jul 2005
    Location
    Hereford
    Posts
    1,414
    Thank Post
    193
    Thanked 247 Times in 120 Posts
    Rep Power
    61

    Thumbs up

    Thanks very much kmount much apreciated

  11. #10


    Join Date
    Feb 2007
    Location
    Northamptonshire
    Posts
    4,657
    Thank Post
    350
    Thanked 789 Times in 710 Posts
    Rep Power
    344
    No problem, if you get stuck fire me a pm.

  12. #11
    contink's Avatar
    Join Date
    Jul 2006
    Location
    South Yorkshire
    Posts
    3,790
    Thank Post
    303
    Thanked 327 Times in 233 Posts
    Rep Power
    117
    This might be a bit more useful or easier to setup on the mysql side of things.

    http://www.edugeek.net/forums/showth...ghlight=backup

  13. #12
    ICTNUT's Avatar
    Join Date
    Jul 2005
    Location
    Hereford
    Posts
    1,414
    Thank Post
    193
    Thanked 247 Times in 120 Posts
    Rep Power
    61
    Just a quick one, what do they following lines do:

    /var/backups/link2backupserver

    just trying to work out what link2backupserver is?

  14. #13

    Geoff's Avatar
    Join Date
    Jun 2005
    Location
    Fylde, Lancs, UK.
    Posts
    11,800
    Thank Post
    110
    Thanked 582 Times in 503 Posts
    Blog Entries
    1
    Rep Power
    223
    Your backup device needs to be accessable from the script. In this case, it needs to be mounted in the directory you've mentioned. It depends on what you backup device actually is though on how to do this.

SHARE:
+ Post New Thread

Similar Threads

  1. help required for my two sons new pcs
    By edie209 in forum General Chat
    Replies: 32
    Last Post: 17th December 2007, 10:11 AM
  2. Calling all CMIS guru's
    By SpecialAgent in forum Educational IT Jobs
    Replies: 2
    Last Post: 14th November 2007, 12:33 PM
  3. Exchange Guru's help needed urgently
    By tosca925 in forum Windows
    Replies: 3
    Last Post: 6th September 2007, 10:37 AM
  4. DNS Guru's advice requested.
    By SpuffMonkey in forum Windows
    Replies: 2
    Last Post: 4th August 2007, 06:08 AM
  5. Wanted: SIMS FMS & Fees Ledger Guru
    By pete in forum MIS Systems
    Replies: 0
    Last Post: 22nd May 2006, 09:05 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •