Topic: Deleting folders via SFTP


I hope someone can help me, Google couldn't. I'm writing a backup script in Ruby and face now a problem deleting old folders.

This is my code right now:

if existing_backups.size > NO_OF_BACKUPS         
 sftp.rmdir("/home/#{SSH_USER}/#{BACKUP_ROOT}/" + existing_backups[0].name)
 backup_deleted = true

I have a sorted array with all existing backups and now i want to delete a backup if the NO_OF_BACKUPS is exceeded. The code won't throw an exception or an error, it simply won't delete the folder. Could someone please tell me, what I am doing wrong?? How can I delete a non-empty folder on my server using Ruby??

Thanks a lot, I'm getting crazy for hours with this problem...

Re: Deleting folders via SFTP


could i solve my problem using Fileutils?! Found some examples, but can't get it to work... Could someone please show me how to do that?!

Thanks in advance!!