NET::SFTP downloading multiple directories.

C

Chris Brand

Hi guys,

Im pretty new to ruby, and I want to re-write a bash script I wrote to
backup some data on an iphone to a local comp, in ruby.

This is the bash version: http://pastebin.com/m1a34a96

Here is what i have in ruby so far: http://pastebin.com/m1c2282c0

What I basically want to do is have an array of remote directories
downloaded via stfp to a local folder in a loop, or something to this
effect, and I cant seem to figure it out...

Any help is greatly appreciated!!

-Chris
 
C

Chris Brand

Ok so I got a little further with this, but its still not working
perfectly... I think the wait method is screwing things up, because I
only get the contents of the first folder.

#!/usr/bin/env ruby

require 'FileUtils'
require 'net/sftp'

$local_dir = '/iBak' + Time.now.strftime("%m_%d_%y")
$user_name = 'root'
$backup_dirs = ['/Applications',
'/var/root/Library/Customize2',
'/var/mobile/Library/Installer',
'/var/mobile/Media/EBooks',
'/var/preferences'
]
puts "Please enter your iPhones IP address:"
$phone_ip = gets.chomp!
puts "Now your password:"
$root_pass = gets.chomp!
puts "\nPress enter to begin..."
gets

FileUtils.mkdir_p $local_dir

Net::SFTP.start( $phone_ip, $user_name, :password => $root_pass ) do
|backup|
dls = $backup_dirs.map { |f| backup.download!( f, $local_dir,
:recursive => true) }
dls.each do |d|
d.wait
end
end

Again, any help would be great!

-Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top