Welcome to the JaguarPC Community
JaguarPC
Sales: (888) 338-5261
Support: (888)-551-3050
Results 1 to 5 of 5

This is a discussion on Custom backup with cron ... in the Shared & Semi-Dedicated forum
Here's my question: I want to backup a section of my website every evening (along with its associated mysql db). For example, if /home/username/www/site1/ contains: ...

  1. #1
    JPC Member
    Join Date
    Aug 2005
    Posts
    3

    Custom backup with cron ...

    Here's my question:

    I want to backup a section of my website every evening (along with its associated mysql db). For example, if /home/username/www/site1/ contains:

    Folder1, Folder2, Folder3, Folder4, Folder5

    then I would only want to backup Folder1, Folder4, and Folder5 (does that make sense?). I understand I could just backup /site1/, but I have two folders containing rather large files that shouldn't be included in the backup.

    So, is this possible using Cron? Can multiple subfolders be included into one backup file? And if so, can certain mysql db's be included in this or do these need to be run separately?

    Thanks for any help,
    Han0522

  2. #2
    the Windlord Gwaihir's Avatar
    Join Date
    Jun 2002
    Posts
    2,562
    Sure, cron is just a "trigger". You need a (relatively small and simple) shell script that does those things for you and then you'll tell cron to run that script every night.

    The script would look something like this:
    - backup Folder1
    - backup Folder4
    - backup Folder5
    - backup the relevant database(s)
    - Pack these four backups together in one compressed file and delete the four intermediate results.

    Two questions however:
    1) Why not include the two large folders in the backup? Is it because you'd like to download that backup every day and don't want it to become too large a download? If so, you might want to look into rsync, a utility that can keep two files (the fresh backup and your local copy) the same by only transferring the differences, thus using little bandwith.
    2) Does the content of your folders actually change without you doing that? For my sites I have the html and php master copy on my own computer and I upload changes from there. If the site went blank, I could just as easily upload all code again. Only the content in the database changes frequently (and is changed by users too), so only of the database I (need to) keep backups.
    Regards,

    Wim Heemskerk
    ---
    Visit MeCCG.net - Cardgaming in J.R.R. Tolkien's Middle-earth
    And Gwaihir.net - The Middle-earth CCG store

  3. #3
    JPC Member
    Join Date
    Aug 2005
    Posts
    3
    Quote Originally Posted by Gwaihir
    Sure, cron is just a "trigger". You need a (relatively small and simple) shell script that does those things for you and then you'll tell cron to run that script every night.

    The script would look something like this:
    - backup Folder1
    - backup Folder4
    - backup Folder5
    - backup the relevant database(s)
    - Pack these four backups together in one compressed file and delete the four intermediate results.

    Two questions however:
    1) Why not include the two large folders in the backup? Is it because you'd like to download that backup every day and don't want it to become too large a download? If so, you might want to look into rsync, a utility that can keep two files (the fresh backup and your local copy) the same by only transferring the differences, thus using little bandwith.
    2) Does the content of your folders actually change without you doing that? For my sites I have the html and php master copy on my own computer and I upload changes from there. If the site went blank, I could just as easily upload all code again. Only the content in the database changes frequently (and is changed by users too), so only of the database I (need to) keep backups.
    Clearly I didn't think my way through this. I'm running a class website with frequent additions of downloadable "class notes". These notes can be up to 10 MB in size and there will be alot of them. I upload these myself so I keep them locally.

    But, as you stated, there's no reason to backup all the files (except once). All of the "uniqueness" of my site (i'm using Post-Nuke) will be stored in the databases.

    So I guess my question now is can I do a one-time backup of the folder (for instance, "/site1/") and then setup cron to do mysql backups every day at midnight?

    Thanks,
    Han0522

  4. #4
    the Windlord Gwaihir's Avatar
    Join Date
    Jun 2002
    Posts
    2,562
    Quote Originally Posted by han0522
    So I guess my question now is can I do a one-time backup of the folder (for instance, "/site1/") and then setup cron to do mysql backups every day at midnight?
    Sure, in several ways. Simplest is to download a ready made backup from CPanel, though it might not have (only) the exact folder you're looking for. Other ways would be to copy it over by FTP or SSH (see Vin's WinSCP tutorial) to some place, with or without making a compressed file of it first.

    As for the database backup, I wrote that down here a while ago. BTW: The most quiet hour on the server is probably a bit later than midnight, so if you are not tied to a specific time, you might want to pick something a bit later like between 3 and 6 am.
    Regards,

    Wim Heemskerk
    ---
    Visit MeCCG.net - Cardgaming in J.R.R. Tolkien's Middle-earth
    And Gwaihir.net - The Middle-earth CCG store

  5. #5
    JPC Member
    Join Date
    Aug 2005
    Posts
    3
    Quote Originally Posted by Gwaihir
    Sure, in several ways. Simplest is to download a ready made backup from CPanel, though it might not have (only) the exact folder you're looking for. Other ways would be to copy it over by FTP or SSH (see Vin's WinSCP tutorial) to some place, with or without making a compressed file of it first.

    As for the database backup, I wrote that down here a while ago. BTW: The most quiet hour on the server is probably a bit later than midnight, so if you are not tied to a specific time, you might want to pick something a bit later like between 3 and 6 am.
    Thanks for the help! I'll look this over and make the necessary changes. I guess I'm fearful of some sort of "attack" on the website; would rather err on the side of caution.

    Now that you meantion it, I have noticed that 4 AM is the "lowest" point in website activity for my site (not sure for everyone else) so it's probably a good idea to back things up then.

    I feel embarassed that I didn't pick up on that from the beginning. Kinda new to this "webmaster" stuff (only excuse I have!).

    Anywho, thx!

    -Han0522

Bookmarks

Posting Permissions

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