diff --git a/commands/sql/sql.drush.inc b/commands/sql/sql.drush.inc
index 6248b41..4bff1e8 100644
--- a/commands/sql/sql.drush.inc
+++ b/commands/sql/sql.drush.inc
@@ -803,18 +803,24 @@ function drush_sql_dump_file(&$site_record) {
     // If the user has set the --dump-dir option, then
     // store persistant sql dump files there.
     $dump_dir = drush_sitealias_get_option($site_record, 'dump-dir');
-    if (isset($dump_dir)) {
-      $dump_file = $dump_dir . '/' . $filename_pattern . '.sql';
-    }
-    // If the --dump-dir option is not set, then store
-    // the sql dump in a temporary file.
-    else {
-      $dump_file = drush_tempnam($filename_pattern . '.sql.');
-      $site_record['dump-is-temp'] = TRUE;
+    if (!isset($dump_dir)) {
+      // If this is a remote site, try to find a writable tmpdir.
+      if (isset($site_record['remote-host'])) {
+        if (!isset($dump_dir)) {
+          $command = _drush_backend_generate_command($site_record, 'drush ev', array('drush_print(drush_find_tmp())'));
+          drush_shell_exec($command);
+          $output = drush_shell_exec_output();
+          $dump_dir = array_pop($output);
+          $site_record['dump-is-temp'] = TRUE;
+        }
+        $dump_file = $dump_dir . '/' . $filename_pattern . '.sql';
+      }
+      else {
+        $dump_file = drush_tempnam($filename_pattern . '.sql.');
+      }
     }
   }
 
-
   return $dump_file;
 }
 
