Index: dumper.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/dumper/dumper.module,v
retrieving revision 1.7.2.5
diff -u -p -r1.7.2.5 dumper.module
--- dumper.module	17 Dec 2009 16:05:50 -0000	1.7.2.5
+++ dumper.module	21 Jan 2010 14:55:08 -0000
@@ -7,7 +7,7 @@
  * Be careful for this permission!
  */
 function dumper_perm() {
-  return array('dump sql data');
+  return array('dump sql data', 'dump files');
 }
 
 /**
@@ -71,6 +71,7 @@ function dumper_form(){
   );
 
   $form['#submit'][] = 'dumper_form_submit';
+  $form[]['#value'] = '<div>' . l(t('Download Files'), 'dumper/get_files') . ' ' . t('(Files Directory packed in a .tgz file)') . '</div>';
 
   return $form;
 }
@@ -216,5 +217,50 @@ function dumper_menu() {
     'type'             => MENU_NORMAL_ITEM,
   );
 
+  $items['dumper/get_files'] = array(
+    'title'            => t('Dump DB'),
+    'description'      => t('Download site files packed in a tgz.'),
+    'page callback'    => 'dumper_get_files',
+    'access arguments' => array('dump files'),
+    'type'             => MENU_CALLBACK,
+  );
+
   return $items;
 }
+
+/**
+ * Dump the files directory into a files.tgz for downloading
+ */
+function dumper_get_files() {
+  // Temporary file location
+  $filename = file_directory_temp() . '/' . session_name() . '-files.tgz';
+
+  // Files directory
+  $directory = explode('/',file_directory_path());
+  $files = array_pop($directory);
+  $dir_path = implode('/', $directory);
+
+  // The command to be executed
+  $exec = 'tar -cf ' . $filename;
+
+  if(!empty($dir_path)) {
+    $exec .= ' -C '. $dir_path;
+  }
+
+  $exec .= ' ' . $files;
+
+  // Executing the command on the system
+  $result   = system($exec);
+
+  // Return the file
+  if (file_exists($filename)) {
+    file_transfer($filename, array('Content-type: application/x-gzip', 
+      'Content-Disposition: attachment; filename="files.tgz"', 
+      'Content-Type: application/force-download', 
+    ));
+  }
+  else {
+    drupal_set_message(t('Unable do dump files'),'error');
+    drupal_goto('/admin/settings/dumper');
+  }
+}
