delete folder older than 31 day from root folder - robocopy incremental backup
-
Monday, February 11, 2013 2:56 PM
hello
I want to configure robocopy to perform full backup every first day at month (scheduled task, no problem) and after that all other days incremental 6x par day (scheduled task, no problem). In this way I will have versioning so worker can go back for hour if needed.
I have d:\backup\ folder and here robocopy make subfolders with backups, naming like this:
D:\backup\
\backup\Full 11-02-2013 09h-00m
\backup\Incremental 12-02-2013 09h-00m
\backup\Incremental 12-02-2013 10h-00m
\backup\Incremental 12-02-2013 11h-00m
\backup\Incremental 12-02-2013 12h-00m
\backup\Incremental 12-02-2013 13h-00m
\backup\Incremental 12-02-2013 14h-00m
\backup\Incremental 12-02-2013 15h-00m
I need script which will delete subfolder from root d:\backup\ older than 30 days, one each day. In this way I will have always 30/31 subfolders. Script will be scheduled to run every day.
thanks
All Replies
-
Monday, February 11, 2013 3:13 PMModerator
I need script ...
Hi,
What does your script look like so far? This is a forum for help answer scripting questions. We don't really have the resources to write scripts on demand for others for free. Have you tried searching the web and/or the script repository?
Bill
-
Monday, February 11, 2013 5:37 PM
hello
I want to configure robocopy to perform full backup every first day at month (scheduled task, no problem) and after that all other days incremental 6x par day (scheduled task, no problem). In this way I will have versioning so worker can go back for hour if needed.
I have d:\backup\ folder and here robocopy make subfolders with backups, naming like this:
D:\backup\
\backup\Full 11-02-2013 09h-00m
\backup\Incremental 12-02-2013 09h-00m
\backup\Incremental 12-02-2013 10h-00m
\backup\Incremental 12-02-2013 11h-00m
\backup\Incremental 12-02-2013 12h-00m
\backup\Incremental 12-02-2013 13h-00m
\backup\Incremental 12-02-2013 14h-00m
\backup\Incremental 12-02-2013 15h-00m
I need script which will delete subfolder from root d:\backup\ older than 30 days, one each day. In this way I will have always 30/31 subfolders. Script will be scheduled to run every day.
thanks
I recommend suing ShadowCopy which can be set to retain 'N' copies of a file. It uses less disk space becuse only changed files will be copied. Search for teh Microsoft Shadow Copy Service.
¯\_(ツ)_/¯
-
Tuesday, February 12, 2013 8:23 AM
I need script ...
Hi,
What does your script look like so far? This is a forum for help answer scripting questions. We don't really have the resources to write scripts on demand for others for free. Have you tried searching the web and/or the script repository?
Bill
first step is that robocopy make full backup from c:\radni to D:\Backup\Full 11-02-2013 15h-32m (naming sheme is: type of backup, date and time in folder name) and after backup is complete archive attribute and read-only attribute is cleaned/off. Log file is placed in root d:\backup folder with same naming sheme as for folder.
@echo off
attrib -r c:\radni\*.*
set year=%date:~10,4%
set month=%date:~4,2%
set day=%date:~7,2%
SET Now=%Time: =0%
SET Hours=%Now:~0,2%
SET Minutes=%Now:~3,2%
Robocopy "c:\radni" "d:\backup\Full %month%-%day%-%year% %hours%h-%minutes%m" /s /r:1 /w:1 /log:"d:\backup\Full_%month%-%day%-%year% %hours%h-%minutes%m.txt" /NP
attrib -a -r c:\radni\*.*step 2 is incremental backup where robocopy backup only changed files with archive attribute set/on. Log file is placed in root d:\backup folder with same naming sheme as above.
@echo off
set year=%date:~10,4%
set month=%date:~4,2%
set day=%date:~7,2%
SET Now=%Time: =0%
SET Hours=%Now:~0,2%
SET Minutes=%Now:~3,2%
Robocopy "c:\radni" "d:\backup\Incremental %month%-%day%-%year% %hours%h-%minutes%m" /s /m /r:1 /w:1 /log:"d:\backup\Incremental_%month%-%day%-%year% %hours%h-%minutes%m.txt" /NPThis backup sheme work really good and is free, but I want to have only backups 1 month old or younger, everything older will be deleted. So, I need script which will delete folders from root d:\backup folder older than 1 month. Ideally that I can put script in d:\backup folder and script delete folders from own root. In this way I will avoid changing drive letters problems.
-
Tuesday, February 12, 2013 9:06 AM
Deleting files or folders based on age is a VFAQ in this forum. Did you check the Script Repository for sample scripts?I need script which will delete folders from root d:\backup folder older than 1 month.
-
Tuesday, February 12, 2013 9:14 AMyes, but cant find some script which I will understand. I am not programmer.
-
Tuesday, February 12, 2013 10:11 AM
yes, but cant find some script which I will understand. I am not programmer.
Then it I time for you to learn. This is not a forum for writing custom scripts. It is a forum for those using or learning scripting. If you cannot learn then you can hire a consultant. A consultant can write your scripts for you. That is how this industry works. It is not about doing your work, that you get paid for, for you. It is not about free script writing so that you can have a job.
Look into the "Learn" menu item. Scripting is not really all that hard. If you consider yourself a technician then you can learn to script. Mosst companies now require script proficiency as a fundamental for employment for even basic "help desk" jobs.
http://technet.microsoft.com/en-us/scriptcenter/dd793612.aspx
¯\_(ツ)_/¯
- Marked As Answer by Bill_StewartMicrosoft Community Contributor, Moderator Tuesday, March 19, 2013 7:11 PM

