I have configured Windows Backup and Restore function on Windows 7 Professional desktops to make daily backup on a network share placed on a Windows Server 2012. (BTW It's a pity that this utility does not have an option to use currently logged in user's credentials especially Active Directory user's credentials. Instead it is necessary to enter fixed user's credentials. Thus password will not update when changed in Active Directory.) This utility also does not have any maintenance mechanism for automatically removing old backup versions. So it will produce a lot of outdated data quickly filling server's disk space.
Now I have such a situation in directory structure (this is only for one user but there are many other users' folders in 'Users' catalog):
Users ├─agnes.microt │ ├─AGNES-PC │ │ ├─Backup Set 2014-02-24 060001 │ │ │ ├─Backup Files 2014-02-24 060001 │ │ │ ├─Backup Files 2014-02-25 091044 │ │ │ ├─Backup Files 2014-02-26 092458 │ │ │ └─Catalogs │ │ └─Backup Set 2014-02-27 091933 │ │ ++ ├─Backup Files 2014-02-27 091933 │ │ ++ └─Catalogs
What I want to do is to delete (by run a batch file in a daily scheduled task) all 'Backup Set' folders which date is older than a day leaving only the latest backup set for each user. It would be simple but there are also users which are not present in company for a few days. Thus their latest backup set should stay on the server in spite of the fact that it is outdated.
I have made such a batch:
forfiles /D -1 /P D:\User /M "Backup Set *" /S /C "cmd /c if @ISDIR==TRUE (dir /b /a:d | find /c \"Backup Set\") | (if not %1==\"1\" (rmdir /s /q @file))"
I don't know how to pass 'dir+find' result to 'if' command which follows it.
Any help would be appreciable. As well as any other open mind suggentions regarding the topic of this question/problem.