The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

how can I create a cron to backup only one directory?

Discussion in 'General Discussion' started by dlevens, Jul 13, 2004.

  1. dlevens

    dlevens Member

    Joined:
    Jun 20, 2004
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    1
    I have a huge site but 90% of it only needs to be backed up once in a few months. But I have a few folders that I would like to backup daily or weekly. How can I schedule a cron that will backup just one directory by making a compressed archive at my root for me to download?

    Dennis
     
  2. PWSowner

    PWSowner Well-Known Member

    Joined:
    Nov 10, 2001
    Messages:
    2,948
    Likes Received:
    3
    Trophy Points:
    38
    Location:
    ON, Canada
    A script to do that wouldn't be very complicated. How soon would you need it?
     
  3. dlevens

    dlevens Member

    Joined:
    Jun 20, 2004
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    1
    no rush, right now I sorta pieced together the following:

    tar.sh
    -------
    tar -cf archive.tar /home/myuserid/public_html/squirrelmail


    but not sure I am doing this right. I also need to schedule this via a cron job and then quickly disable the cron so it does not keep running.

    What sucks is I do not have shell access and cannot use phpshell or anything, nor can I use sudo. Cron seems to be the only way to run it.

    Dennis
     
  4. aboyz

    aboyz Well-Known Member

    Joined:
    Sep 29, 2003
    Messages:
    104
    Likes Received:
    0
    Trophy Points:
    16
    yeah.

    What you want to do is

    set a cron job to this

    tar -zcvf /home/username/*

    damn. I got a nice script that when you tar it up. It set the date in there so you know which tar file is which as the day goes on. :)

    I'll look for the old script and post it here ok

    You can also set a cron job to backup the mysql databases as well.
     
  5. dlevens

    dlevens Member

    Joined:
    Jun 20, 2004
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    1
    that would be sweet. Any way to make the script with a %1 so that when I run the cron I can just say tar.sh /home/myuserid/public_html/squirrelmail? This way I never need to modify the script, just would need to run the cron and specify which folder at the cron line.

    Dennis
     
  6. dlevens

    dlevens Member

    Joined:
    Jun 20, 2004
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    1
    any luck finding that script that would append time and date? I tried your tar command:

    tar -zcvf /home/myuserid/public_html/squirrelmail/*

    but it failed, it first gave this message:
    followed by a directory listing of all my files then gave this message:


    Dennis
     
    #6 dlevens, Jul 15, 2004
    Last edited: Jul 15, 2004
Loading...

Share This Page