Skip to content

Delete directories recursive on Hetzner Storage Box

Among other external solutions, I store some data on Storage Boxes from Hetzner. The Storage Box allows you to have sub-accounts, so for every server and system storing data there, I use a separate account. For each sub-account, one can select a subdirectory where the data is stored, and the sub-account then can only see this data. The Admin account can see all data, and see all directories.

The usual way I access the Storage Box from other systems is by using sftp protocol from ssh (don't confuse this with the "other" sftp). That's all good, until I remove a sub-account and want to delete the subdirectory with the data. The server doesn't know "rm -r" for recursive deletion, which means I have to traverse into every directory, delete all files, then delete the empty directories. And the encrypted backup I'm using is creating plenty of subdirectories.

Or I find a better tool.

 

The good old Midnight Commander once again comes to the rescue.

Hetzner uses a somewhat unusual setup to connect sftp: it's running on Port 23, not 22. In MC either click on the "left" or "right" menu option, and select "SFTP link". The format of the link is:

sftp://user@userhost.your-storagebox.de:23/home

Without the /home the login works, but then the account does not have permissions to see the current directory. All the data is under /home.

From there it's easy to select one or multiple directories, and hit Delete (F8). mc will traverse into the directories, scan them for what needs to be deleted, and then send single delete commands for each file and directory.

Trackbacks

No Trackbacks

Comments

Display comments as Linear | Threaded

No comments

Add Comment

Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.
E-Mail addresses will not be displayed and will only be used for E-Mail notifications.
To leave a comment you must approve it via e-mail, which will be sent to your address after submission.
Form options