# how to take backup and delete OLD files



## qutesanju (May 18, 2009)

hi experts,
I need to take a backup and delete old files present on c:\testfolder ,older than 1 month or 6 month than current date ,at the same time I need to ZIP all those files also ,how can I achieve this?
e.g my files are like this
c:\testfolder\Action_2009-11-23_12916.csv
c:\testfolder\Waste_2009-11-23_13540.csv
...............
etc
I have to put all those files into 
c:\testfolder\Archive\6monthsBackup.zip

Pls help, me

Thanks guys.


----------



## Squashman (Apr 4, 2003)

I am confused by the older than 1 month or 6 months statement.

Do you want to archive the files to a zip file based on the created date or last modified date?

What zip program do you have on your computer now?


----------



## TheOutcaste (Aug 8, 2007)

I should type faster
I have the same questions as Squashman.

I'm assuming you want to use the date that is part of the file name, rather than the file system created/modified date.
If you Zip and delete files older than 1 Month, there won't be any files older than 6 months, so I'm not sure what you would be putting into a 6 month backup.

I'd assume this is something done once a month? If done daily, your 1 month archive would only contain files for one day. And what about backups for files less than one month old?
Is what you want more like this:
Backup files daily.
Then, each month:
Zip files from previous month into a zip archive and delete the archived files from the testfolder and the backup folder. So Feb 1, you would archive all Jan files
*OR*
Zip files older than one month into a zip archive and delete the archived files from the testfolder and the backup folder. So Feb 1, you would archive all Dec files.

Or do you always want to have just the last 30 days in testfolder, then archive the backup folder using one of the above options?

Also:
What OS will this be running under?
What Zip porgram are you going to be using?
Will you be using command line switches for the GUI version, or using a command line version of the Zip program, if it has one?
Will the backup location be another hard drive on the same PC, a shared folder on another PC, or online storage of some kind?
(A folder on the same hard drive is not a good choice for a backup location)
Will the backup location be a removable device, like an external drive, USB Flash drive, or Memory card that might not always be connected?

Also, will the date in the file name always be a two digit day and month, i.e., include a leading 0?


----------



## scrfix (May 3, 2009)

Guys,

I agree that he could have been much more clear on the subject however being somewhat of an expert of not providing all the information to squashman time and time again (lol) I believe what he meant to say was either NOT the word OR but up to

OR 

More feasible. He would like to do:
1. A daily backup or nightly in this case and backup and archive into a zip file any files that are over a month old up to 6 months old.

2. Anything older than 6 months can be deleted from the archive so the zip file does not become enormous over time.

If this is indeed the case it would involve not only looking at the folder for the date however also looking at the compressed folder.

Just my two cents because I am about to post a different question among the same lines but mine is much much easier. I will post mine in a new thread.


----------



## qutesanju (May 18, 2009)

I want to take backup of 6 month and ZIP all those files,provided it should take date from file name Waste_2009-11-23_13540.csv
I'm using windows OS and pentazip is the software utility I'm using


----------



## scrfix (May 3, 2009)

Okay,

There seems to be a communication issue here because you are not providing us with enough information to help you out. Let me attempt to be more specific.



qutesanju said:


> I want to take backup of 6 month and ZIP all those files


1. Do you want the backup to run daily? If so, this will end up with tons of zip files with only 1 day in it? Are you running it every 6 months to store that last 6 months worth of data? If this is it, this is not very efficient. Being very specific, let us know step by step.

Example: 
I would like to have the backup run (daily, weekly, monthly, semi-annually, etc etc etc). There is 1 file from one computer in C:/testfolder every day. OR There are 15 files from 15 computers saved in C:/testfolder every day.

Step 1: I want for the backup program to read the file name and look at the date in the file name. The date will always be formatted in (2009-01-02, 2009-1-2, etc etc) OR The date will change from time to time. It could be (09-01-02, 09-1-2, etc etc)

Step 2: I would then like for it to take the file name and based upon that look for any files that are older than 6 months.

Step 3: So on and so on. The more specific the easier it is to help you.



qutesanju said:


> provided it should take date from file name Waste_2009-11-23_13540.csv


2. We have established that you want to utilize the date in the name. Will the date in the name ALWAYS be in that format? Will the date be 2009-01-02 OR will the date be 2009-1-2 OR 09-01-02 OR 09-1-2 (I think you get my point).



qutesanju said:


> I'm using windows OS


3. What Windows Version? XP Home, XP Pro, Vista Home Basic, Vista Home Premium, Vista Business, Win 7, Server 2003, Server 2003 small business, etc etc etc etc. You can find this information out by holding down the Windows Key on your keyboard and pushing the R key one time and letting up. This will bring up the Run dialogue box. Type in winver and push enter on your keyboard. (Windows Key is the key with the Microsoft Logo on it usually found in the lower left of the keyboard if you are on a desktop computer and can be in the upper right on a laptop computer) (Windows Key+R).



qutesanju said:


> pentazip is the software utility I'm using


4. Do you know anything about Pentazip? Does it have command line parameters? If you don't know this answer, this is okay. However TheOutCaste was asking if you wanted to use command line switches for the Graphic User Interface or if you didn't care about that and wanted to use the command line version, if Pentazip even has one. Does it matter what program your using as long as it gets zipped. If not, then I believe we can utilize the one that comes with Windows based upon which version of Windows OS you are running asked above.

5. Where do you want the files backed up to?
(A folder on the same hard drive is NOT a good choice for a backup location)
Will it be an external drive?
Will this be a shared folder over a network, online storage?
Will this be a Flash or Thumb Drive or Memory Card?


----------



## qutesanju (May 18, 2009)

Please find the answers as below
1. I dont want to run backup daily ,instead I wil be running ot for yearly mode or 6 months mode .initially pls help me in running yearly mode.

Step1 
Date will always remain same 2009-01-02

So 
There are 15 files from C:/testfolder saved in C:/backupfolder every year.


Yes I want to utilize the date in the name

I will be using windows server 2003 edition.

Im not sure about pentazip. I wanted to use command line switches only 

Path for my backup folder will be c:\testfolder as input path and c:\testfolder\backup will be my backed up path


----------

