There are many great features available to you once you register at Neowin, including:

  • Richer content, access to many features that are disabled for guests like commenting on the front page
  • Access to a great community, with a massive database of experience on hard & software issues, gaming and recreational activities, and more
  • Access to the Neowin IRC - you could make a friend from across the world and talk to them live
  • Access to Neowin contests & subscription offers and forums that are not open to guests/li>
  • It's simple, and FREE! · Register here

Question about how to accomplish this:


 Share

Recommended Posts

My outdoor cameras record to the hard drive, and at night I have SyncBackFree copy the files to my external hdd and to the cloud. I only really need to keep the files for a few weeks, or a month, and then I want to delete them from at least the local system and the external hdd. What is the best method to accomplish deleting the files after a set time.

Link to comment
Share on other sites

You can setup an automated task in Windows to delete files after a certain time frame. Since you know the direct paths to the files, the link below should help setup the command and how to setup a scheduled task:

https://pureinfotech.com/delete-files-older-than-days-windows-10/

  • Like 1
Link to comment
Share on other sites

On 19/03/2022 at 19:59, Jester124 said:

You can setup an automated task in Windows to delete files after a certain time frame. Since you know the direct paths to the files, the link below should help setup the command and how to setup a scheduled task:

https://pureinfotech.com/delete-files-older-than-days-windows-10/

Thanks for the link, my question is would it be best to run this command from the CCTV system, otherwise I would have to figure out how to address the computer via command line.

Link to comment
Share on other sites

On 20/03/2022 at 06:24, jnelsoninjax said:

Thanks for the link, my question is would it be best to run this command from the CCTV system, otherwise I would have to figure out how to address the computer via command line.

If you don't like using the command line, there are a few options.

  1. First, use a good backup app that supports scheduling, incremental backup, and retention policy. Veeam Agent Free can do this. (It doesn't cost you money but you'll get a call from their sale agent.) There are other backup apps with these feature, but I don't know any free ones. I use Macrium Reflect. Once you get such a backup app, tell it to purge backups older than one month.
  2. Write it yourself. While we were at school, we were taught C# or Python. I opted C#. Writing an app that displays files older than a certain date was one of our assignments. It could be modified to copy those files. The File class of the System.IO namespace helps you.
  • Thanks 1
Link to comment
Share on other sites

On 19/03/2022 at 21:54, jnelsoninjax said:

Thanks for the link, my question is would it be best to run this command from the CCTV system, otherwise I would have to figure out how to address the computer via command line.

You should be able to run that from the CCTV system as long as it is running Windows and should not have any impact on the system. That system would have will have access to both the local and remote storage. If it is running Linux, you can do this using some Bash scripting and a cron job. Probably should have asked if you are using Windows or Linux on the CCTV system.

If you take Fleet's advice, a 3rd option for doing this besides C# or Python will be Powershell on Windows machines.

  • Thanks 1
Link to comment
Share on other sites

On 20/03/2022 at 10:12, Jester124 said:

You should be able to run that from the CCTV system as long as it is running Windows and should not have any impact on the system. That system would have will have access to both the local and remote storage. If it is running Linux, you can do this using some Bash scripting and a cron job. Probably should have asked if you are using Windows or Linux on the CCTV system.

If you take Fleet's advice, a 3rd option for doing this besides C# or Python will be Powershell on Windows machines.

OK, well the CCTV system is Windows, but it does not have access to the cloud backup or the external HDD, those are both accessed on my system, I suppose I could modify the command to clear the external and the cloud from my system, but realistically I should only need to do that once, if the command is successfully running on the other system. Am I thinking this out correctly?

Link to comment
Share on other sites

On 20/03/2022 at 09:25, jnelsoninjax said:

OK, well the CCTV system is Windows, but it does not have access to the cloud backup or the external HDD, those are both accessed on my system, I suppose I could modify the command to clear the external and the cloud from my system, but realistically I should only need to do that once, if the command is successfully running on the other system. Am I thinking this out correctly?

So just to make sure, you are using your non-cctv system for moving the backups and uploading to the cloud? If so, then you would be right that the command would need to run from there as it has access to both locations you want to access. If you wanted the CCTV system to do it, you would want to that to have access to the backup locations. If this does not have the access, any form of data control would need to be put on the system actually handling the moving and syncing and is only required on the one.

 

If you were to run it solely on the CCTV system, from the sound of your setup, it would only clean up its own local files, where if you run it on the system currently doing the backups, it can remove the files from all locations and would only need to be managed in one spot.  Hope that helps

  • Thanks 1
Link to comment
Share on other sites

On 20/03/2022 at 18:43, Jester124 said:

So just to make sure, you are using your non-cctv system for moving the backups and uploading to the cloud? If so, then you would be right that the command would need to run from there as it has access to both locations you want to access. If you wanted the CCTV system to do it, you would want to that to have access to the backup locations. If this does not have the access, any form of data control would need to be put on the system actually handling the moving and syncing and is only required on the one.

 

If you were to run it solely on the CCTV system, from the sound of your setup, it would only clean up its own local files, where if you run it on the system currently doing the backups, it can remove the files from all locations and would only need to be managed in one spot.  Hope that helps

I use Mega Sync as the cloud to backup to, is there anyway to access Mega via the command line? I know it as a local cache, but I don't know if that would work or not.

Link to comment
Share on other sites

On 21/03/2022 at 03:42, jnelsoninjax said:

I use Mega Sync as the cloud to backup to, is there anyway to access Mega via the command line? I know it as a local cache, but I don't know if that would work or not.

It works, don't worry. A command-line app is just another app. As long as it places the file into Mega Sync's folder, Mega Sync will upload it.

 

However, there indeed is a utility called Mega CMD for interfacing with Mega.nz from the command-line.

Link to comment
Share on other sites

On 21/03/2022 at 02:04, Fleet Command said:

It works, don't worry. A command-line app is just another app. As long as it places the file into Mega Sync's folder, Mega Sync will upload it.

 

However, there indeed is a utility called Mega CMD for interfacing with Mega.nz from the command-line.

Thank you for the link!

Link to comment
Share on other sites

OK, Mega CMD doesn't accept the ForFiles command. I tried from the regular command line using this command:


ForFiles /p "C:\Users\jnels\Documents\MEGAsync\CCTV" /s /d -30 /c "cmd /c del /q @file"

But it just sits there and does not do anything. I have modified the command to work on the external HDD and it worked just fine, as it did on the CCTV system. Any idea as to why it would not work? I am running it as Admin

Link to comment
Share on other sites

On 21/03/2022 at 20:14, jnelsoninjax said:

OK, Mega CMD doesn't accept the ForFiles command. I tried from the regular command line using this command:

 

ForFiles /p "C:\Users\jnels\Documents\MEGAsync\CCTV" /s /d -30 /c "cmd /c del /q @file"

 

But it just sits there and does not do anything. I have modified the command to work on the external HDD and it worked just fine, as it did on the CCTV system. Any idea as to why it would not work? I am running it as Admin

Looking at some materials for MegaCMD, it looks like it may use unix based commands. Try running the following with the correct path to see if it finds anything:
 

find <Path_To_Old_Files> -type f -mtime +30 -print


That should hopefully show you file older than 30 days old. If that works and catches the files you want correctly, you can then run the following to automate the removal:
 

find <Path_To_Old_Files> -type f -mtime +30 | xargs rm -f

 

Just make sure that the first one run is correct before implementing the second as the second one will permanently remove the files once it is run.

You will only need to run the second one during your cleanup once you have the search correct going forward.

Link to comment
Share on other sites

On 22/03/2022 at 15:04, Jester124 said:

Looking at some materials for MegaCMD, it looks like it may use unix based commands. Try running the following with the correct path to see if it finds anything:
 

find <Path_To_Old_Files> -type f -mtime +30 -print


That should hopefully show you file older than 30 days old. If that works and catches the files you want correctly, you can then run the following to automate the removal:
 

find <Path_To_Old_Files> -type f -mtime +30 | xargs rm -f

 

Just make sure that the first one run is correct before implementing the second as the second one will permanently remove the files once it is run.

You will only need to run the second one during your cleanup once you have the search correct going forward.

It does not recognize the command with the switches.

Link to comment
Share on other sites

I was mixing my Unix mind and didn't completely reference the knowledge base:

https://github.com/meganz/MEGAcmd/blob/master/UserGuide.md

Looks like "find" is correct, but it does not list support for the -type parameter. Try the following for the search part:

 

Quote

find <Path_To_Old_Files> -l -mtime +30d

They look to have it a little different then what I normally do it, but this should hopefully work. If that lists out properly, you can remove the "-l" as that is the list flag that should print your search to the terminal.

 

Once that is done, the pipping ("| xargs rm -f") should work for the automation to do the actual removal. Again, test the search before adding the last part.

Link to comment
Share on other sites

On 22/03/2022 at 05:44, jnelsoninjax said:

OK, Mega CMD doesn't accept the ForFiles command.

With respect, your attention to details needs a little improvements. You're trying to mix and match two different incompatible approaches.

 

Now, please pay close attention.

  • The ForFiles command is only valid inside Windows Command Prompt or batch files (.bat / .cmd). For that approach, you need these three things only:
    1.  Mega Sync
    2. a batch file for copying files into Mega Sync's data folder
    3. Task Scheduler for running said batch file.

The ForFiles command goes into the batch file. (You probably test it in Command Prompt first.)

  • You can modify the above workflow by replacing Mega Sync with Mega CMD. Mega CMD isn't a generic command prompt. It is a command-line app with its own set of instructions. It is for intelligent people who have both experience and aptitude in using CLIs, so that they can extricate themselves from trouble. You can open it and issue a help command to see what it does. However, it is so advanced that its developers haven't documented it well.

Once again, my recommended approach is a GUI backup app that can do all of these, i.e., make incremental backups, delete old backup, and package your videos in backup containers so as to reduce their chance of corruption.

Link to comment
Share on other sites

OK, thanks for your input @Fleet CommandI configured SyncBack to delete files older than 30 days, I have already run the other command on the CCTV system, and my external HDD

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.