diff --git a/includes/destinations.filesource.inc b/includes/destinations.filesource.inc
index 0413299..cf3a81c 100644
--- a/includes/destinations.filesource.inc
+++ b/includes/destinations.filesource.inc
@@ -130,9 +130,24 @@ class backup_migrate_files_destination_filesource extends backup_migrate_destina
       return FALSE;
     }
     if ($handle = @opendir($dir)) {
+       // If there is a scheme on the basedir, let stream wrappers handle IO.
+      $scheme = file_uri_scheme($dir);
       while (($file = readdir($handle)) !== FALSE) {
         if ($file != '.' && $file != '..' && !in_array($file, $exclude)) {
-          $file = realpath($dir . '/' . $file);
+          // If no scheme, try the filesystem directly.
+          if ($scheme == FALSE) {
+            $file = realpath($dir . '/' . $file);
+          }
+          // If scheme, work through the PHP Streams API.
+          else {
+            $target = file_uri_target($dir);
+            if (empty($target)) {
+              $file = $scheme . '://' . $file;
+            }
+            else {
+              $file = $scheme . '://' . $target . '/' . $file;
+            }
+          }
           if (is_dir($file)) {
             $subdir = $this->get_files_to_backup($file, $settings, $exclude, $base_dir);
             // If there was an error reading the subdirectory then abort the backup.
