Forum/Servizi di Hosting/Rack Space Cloud

Zip and Tar on RackSpaceCloud

Franco Farnedi
posted this on October 22, 2011 10:59

Questa nota può essere utile per effettuare un backup di un sito su RSC, oppure per scaricare o caricare velocemente una copia zippata dell'intero sito.

Alcune note sui tempi di esecuzione:

Franco Farnedi: is there a way to "start" the cronjob immediatly?
Franco Farnedi: i need to wait for a specific time
Franco Farnedi: and i need to do once only
Jeremy Z: The best way to do that, given how the cron job process works, would be to set it to run daily, then tell it to run in the next couple of minutes. Since it uses CST, that would mean if you set it to run at 5:00 AM, it would run in the next minute.
Jeremy Z: You'd just have to set a specific time for it to run.
Jeremy Z: But that's generally a much more precise way of doing it instead of setting up some sort of "every five minutes" or hourly deal.

 

http://www.rackspace.com/knowledge_center/index.php/Use_cron_to_ext...

 

Use cron to extract and compress (zip & unzip) on Cloud Sites

Article Id: 892 | Cloud Sites | Article



Scripting extraction and compression of files

IMPORTANT NOTE: Please make sure that you set up the cron job "command type" to be Perl to properly execute the shell script (.sh file). Cron jobs that run over 900 seconds (15 minutes) are automatically terminated.

Compressing

If you're scripting file compression, create a file named "compress.sh" to start.

Zip compression

To compress the file to zip format, add these lines to the script:

#!/bin/sh
zip -9pr /PATH/TO/FILES/file.zip /PATH/TO/FILES/  

Where "file.zip" is the name that you assign to the zip file

Tar compression

Put this in the script to compress in tar format:

   #!/bin/sh
  tar -cpvf /PATH/TO/FILES/file.tar /PATH/TO/FILES/   

Where "file.tar" is the name that you assign to the compressed file.

 

Tar.gz compression

Put this in the script to compress in tar format:

   #!/bin/sh
  tar -zcpvf /PATH/TO/FILES/file.tar.gz /PATH/TO/FILES/   

Where "file.tar.gz" is the name that you assign to the compressed file.

Extracting

If you're scripting file extraction, create a file named "decompress.sh" to start.

Zip extraction

Add these lines to decompress from zip format:

   #!/bin/sh                                           
   unzip -o PATH/TO/FILES/file.zip -d PATH TO FILE/FOLDER

Where "file.zip" is the name that you assign to the zip file.

(NOTE: the -o option will force overwrite existing files!)

Tar extraction

Put this in the script to extract from tar format:

   #!/bin/sh  
   tar -xvf /PATH/TO/FILES/file.tar 

Where "file.tar" is the name that you assign to the compressed file.

 

Tar.gz extraction

Put this in the script to extract from tar format:

   #!/bin/sh  
   tar -zxvf /PATH/TO/FILES/file.tar.gz 

Where "file.tar.gz" is the name that you assign to the compressed file.

NOTE: please take into account that "PATH/TO/FILES" needs to be replaced with your Web directory ie: /mnt/stor1-wc2-dfw1/446266/www.domain.net/web/content/