Saved Bookmarks
| 1. |
Solve : Batch backups...? |
|
Answer» i'm using a batch file to copy files (daily) to another location... My issue is, it only updates new files but dosen't TAKE out the old ones (in the new location that is) ... here is the string i'm using... it only updates new files but dosen't take out the old ones (in the new location that is) XCOPY does not have any delete capabilities. Based on the/d switch, only files that have been updated since the last backup will get copied. If a file was not updated, the file in the destination location is still current backup. Do you really want to delete the old files? Yeah I would like the old files deleted.... I would also like to get some back up rotation in there as well... maybe weekly and monthly.... got any ideas? Thanks, MattQuote got any ideas? you betcha! One tried and true method is to keep 3 sets of weekly backups and a daily backup based on the archive bit of a file: Friday: XCOPY D:\ N:\WeeklyBackups_WeekNumber\ /C /S /Y /I ATTRIB -A D:\ /S DEL ALL DAILY BACKUPS DEL OLDEST WEEKLY BACKUP PAST 3 Monday - Thursday XCOPY D:\ N:\DailyBackups_DayOfWeek\ /C /S /Y /I /A The first thing would be to do a weekly (Friday backup). This creates a base backup and flips all the archive bits off. Subsequently, any file that is updated will have it's archive bit flipped on by the system. Each daily backup will include only files with the archive bit on. When each weekly backup occurs, all files will be backed up regardless of the archive bit status. You will also need logic for the weekly backup to delete all the daily backups, clearing space for the coming week and to delete the oldest weekly backup, keeping only the last 3. This is a basic differential backup and while not the fastest method, it makes a restore operation easier. Depending on your system date format, it may be possible to scrape the day of week from the %date% variable. The week number may be more problematical. The devil is in the details of course, so give us a shout out if you need further help. You can have any schedule you CHOOSE for your backups. The example is a framework to show the mechanics of how to develop a backup strategy. Wow... Your starting to blow my mind a little bit... OK... lets say I wanted to create a batch file that deletes certain files and directories WITHIN that file. What would be the CODE to do that? I think this will give me somemore understanding.... Here's the path.. I want the batch file to delete all files and directories inside... N:\dailybackups Thanks for all your help.. MattQuote I want the batch file to delete all files and directories inside... I know there are switches that can be used on both the del and rd commands, but I prefer a more open method that can handle future CHANGES more readily. Code: [Select]@echo off for /f "tokens=* delims=" %%i in ('dir /a-d /s /b N:\dailybackups') do ( del %%i ) for /f "tokens=* delims=" %%i in ('dir /ad /s /b N:\dailybackups') do ( rd %%i ) Good luck. Thanks for the reply... The only issue I have with this code is that it asks me if i really want to delete the folders... is there a way to delete the files and folders without asking? Thanks again.... Matt Code: [Select]@echo off for /f "tokens=* delims=" %%i in ('dir /a-d /s /b N:\dailybackups') do ( echo Y | del %%i ) for /f "tokens=* delims=" %%i in ('dir /ad /s /b N:\dailybackups') do ( echo Y | rd %%i ) This is new to me. I always saw the confirmation messages when wildcards were used. No wildcards here! |
|