Help Compressing a Directory with cron jobs

Discussion in 'PHP' started by jpinheiro, Apr 19, 2009.

  1. #1
    Hello,

    I was wondering if it was possible to Compress a directory and all the containing files into a compress zipped file or another compressed file with php and then the compressed file put into the main directory for later download.

    I want this to be done automatically with cron jobs if possible it will be used to backup uploaded images on my site because i run a free image hosting site and i want everything to be backed up incase something happens and the site goes down.

    The Site is http://PhotoHoster.us/

    I need the Directory:
    http://PhotoHoster.us/graphic
    to be compressed with cronjob and the compressed file to be put here:
    http://PhotoHoster.us/ in the main directory

    Thanks,
    John
     
    jpinheiro, Apr 19, 2009 IP
  2. centralb

    centralb Peon

    Messages:
    26
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You can use the tar command:
    tar cpvf <full/path/to/archivename.tar.gz> <full/path/to/graphicdir>

    You can use PHP's backticks operator: php.net/language.operators.execution or shell_exec: php.net/shell_exec
     
    centralb, Apr 19, 2009 IP