Skip to main content

I was working on having my company's Box files backed up to an on-prem NAS server.


The server ran a sync (not Box Sync, just a sync between my server and Box), and it accidentally restored old files that were deleted. No new files were affected (at least it looks like we're good), but there are redundant and once deleted files hanging around in our folders now.


I changed the settings on the NAS, so the two-way sync is no longer active. It's set to update itself with changes from Box, but not the other way around.


I'm not well versed in APIs, so my "fix" would be to run a report of all the changes for that period and delete these re-uploaded files one-by-one. Does anyone know of an easier way to clean up this mess?

If you have a list of the ids of the files in a csv file, you should be able to create a simple powershell script with our CLI to re-delete the files


Hope this helps, 


Alex, Box Developer Advocate


Alex, thank you for the response!


I was able to connect to my Box environment using the CLI. To test, I figured I would delete a file by itself before going full-scale. But when I try, I get a 404 error:BOX1_h1UU5x4mnDsHEavWhgA9Ig.png


Am I doing something wrong? I ran a report to find these affected files, and I assume Affected ID is what I needed:


BOX1_zk8PQa0XhCrjv6WLNeQklA.png


I'm definitely in our Box, if I run a simple command like "box users" all my users will appear:


BOX1_30YXmk_7ePaCZV8X-vmZIw.png


Any info helps. Thanks again!


Hello!


This is probably because the service account that got created for the CLI is not collaborated into the content you are trying to delete... so it can't find the files. You will want to make as-user calls with a user id that owns the content. 


BOX1_GGsX2nMyFWCo5dKgHcTk8g.png


Hope this helps, 


Alex, Box Developer Advocate


Alex, thanks for the follow up!


I was able to get it working by sharing my highest level folders with my service account:


BOX1_7y-P6Vbt7kVv3b_hnPa4Kg.png


Once I did that, the CLI command is running as it should:


BOX1_fCK2_AhO_4d6Rp7XmK93uQ.png


Yes! You can also collaborate the service account into the content. Sometimes though it's not easy to do that in all the content at once like your folder structure is architected. Glad you got your problem solved! 


Reply