Compress then Delete

Login or Register to Reply

Thread Tools Search this Thread
# 1  
Compress then Delete

Hi all,

Someone please help with a script that will compress a directory for backed up:


Then all the files in the directory are to be deleted right afterwards, emptied out for new files to come in:

home/main/directory2Bcompressed/ <--- emptied

Then the process starts all over. I am looking to have things done bi weekly. The files in the directory are images and videos.

Thanks in advance,
# 2  
Standard zip has options to do most of this. See man page for zip. If you are paranoid, you can zip the files, pull a listing from the zip, compare each file bit for bit between the archive and the disk using cmp and unzip to stdout, log errors for any that are mismatched and only delete those that match. You might want to log and avoid any files that are open, using fuser to check for open()s.
# 3  
i don't have total control over the machine... everything is going to be done through a web interface.
# 4  
Well, your client script can do all these sorts of funtions using tools like wget to substitute web server actions for local ones. Are you archiving on the server, or the client?
# 5  
If i understand what you want you to do, you want to be able to specify a directory and then have it zipped up, but wish to initiate it remotely via a browser.

I would the php command shell_exec();
Then using the zip command, specify what you need done.
Then using the rm command to remove the initial directory.
If you need more elaborate information, don't hesitate to ask Smilie
# 6  
and you can use a cron job for this to run weekly

---------- Post updated at 01:35 PM ---------- Previous update was at 01:34 PM ----------

I have a script like this. if you are interested please let me know. it is done with php
# 7  
If you have shell access or cron can be setup to do with simple 3-4 commands

echo "Compression started"
zip home/main/ home/main/directory2Bcompressed/
cd home/main/directory2Bcompressed/
rm -rf *
Echo "Content deleted from the folder"
echo "DONE!!"

---------- Post updated at 11:23 AM ---------- Previous update was at 11:22 AM ----------

Ahh with php i really dont know how to but you can defiantly get it done but for which you need to enabled
exec or shell_exec which is not recommended by security prospect of your server.
Login or Register to Reply

Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
Script to compress and delete the older logs
Hello Guys, Can you please help me with a script which zips the older log files(1-2 weeks) and delete them? I want to run the script manually instead of setting it up in a cron job. Appreciate your help. Regards, Kris... Shell Programming and Scripting
Shell Programming and Scripting
Compress and delete folders
Hello, can someone help me to create a short script that tar.gz all folders form a specific folder and the delete the folders themself (without deleting the tar.gz created files)? Moreover I'd like to add it on crontab and run it each day. For example: in /tmp I have: /tmp/test/test1...... Shell Programming and Scripting
Shell Programming and Scripting
Issue: Compress in unix server and FTP to windows and open the compress file using Winzip
Hi All ! We have to compress a big data file in unix server and transfer it to windows and uncompress it using winzip in windows. I have used the utility ZIP like the below. zip -e <newfilename> df2_test_extract.dat but when I compress files greater than 4 gb using zip utility, it...... UNIX for Dummies Questions & Answers
UNIX for Dummies Questions & Answers
Need help to compress
People i have files.arc i need to compress one by one...but they need to have the same date for example jan 30 1234.arc jan 30 12334.arc jan 30 rejrne.arc jan 30 e423e4.arc jan 30 afdhnfhd.arc jan 31 aresdfds.arc I need to compres the jan 30 .arc only thank you very much... UNIX for Dummies Questions & Answers
UNIX for Dummies Questions & Answers
How to compress & delete files in ksh
Hi, I would like to know how to go about writing a script to compress & deleate old files from /var/mqm/log file system. I am a complete beginner and would love it if someone could actually give me the code for this. Thank you.... Shell Programming and Scripting
Shell Programming and Scripting