README.txt 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. Backup and Migrate
  2. ------------------
  3. This module makes the task of backing up a site's Drupal database, code and
  4. all uploaded files and of migrating data from one Drupal install to another
  5. easier.
  6. Database backup files are a list of SQL statements which can be executed with a
  7. tool such as phpMyAdmin or the command-line mysql client. File and code backup
  8. files are tarballs which can be restored by extracting them to the desired
  9. directory.
  10. Installation
  11. -------------------------------------------------------------------------------
  12. * Put the module in the Drupal modules directory and enable it via
  13. admin/modules.
  14. * Go to admin/people/permissions and grant permission to any roles that need to
  15. be able to backup or restore the database.
  16. * Configure and use the module at admin/config/system/backup_migrate.
  17. OPTIONAL:
  18. * To drop all tables before import, expand "Advanced options" panel under the
  19. "Restore" and "Saved backups" tabs and tick the option.
  20. * Enable token.module to allow token replacement in backup file names.
  21. * To Backup to Amazon S3:
  22. - Download the most recent version from:
  23. https://github.com/tpyo/amazon-s3-php-class
  24. - Or clone it with command:
  25. git clone https://github.com/tpyo/amazon-s3-php-class.git s3-php5-curl
  26. - Rename the unzipped folder to s3-php5-curl
  27. The most recent version of the library known to work is 0.5.1.
  28. Advanced settings
  29. -------------------------------------------------------------------------------
  30. Several advanced options are available from the Advanced Settings page:
  31. * admin/config/system/backup_migrate/settings-advanced
  32. These settings should be handled with care, it is recommended to leave them at
  33. their defaults unless there is a specific need to modify them.
  34. Additional requirements for LigHTTPd
  35. -------------------------------------------------------------------------------
  36. Add the following code to the lighttp.conf to secure the backup directories:
  37. $HTTP["url"] =~ "^/sites/default/files/backup_migrate/" {
  38. url.access-deny = ( "" )
  39. }
  40. It may be necessary to adjust the path to reflect the actual path to the files.
  41. Additional requirements for IIS 7
  42. -------------------------------------------------------------------------------
  43. Add the following code to the web.config code to secure the backup
  44. directories:
  45. <rule name="postinst-redirect" stopProcessing="true">
  46. <match url="sites/default/files/backup_migrate" />
  47. <action type="Rewrite" url=""/>
  48. </rule>
  49. It may also be necessary to adjust the path to reflect the actual path to the
  50. files.
  51. VERY IMPORTANT SECURITY NOTE
  52. -------------------------------------------------------------------------------
  53. Backup files may contain sensitive data and, by default, are saved to the web
  54. server in a directory normally accessible by the public. This could lead to a
  55. very serious security vulnerability. Backup and Migrate attempts to protect
  56. backup files using a .htaccess file, but this is not guaranteed to work on all
  57. environments (and is guaranteed to fail on web servers that are not Apache). It
  58. is imperative to test to see if the site's backup files are publicly
  59. accessible, and if in doubt do not save backups to the server, or use the
  60. destinations feature to save to a folder outside of the site's webroot.
  61. Other warnings
  62. -------------------------------------------------------------------------------
  63. A failed restore can destroy the database and therefore the entire Drupal
  64. installation. ALWAYS TEST BACKUP FILES ON A TEST ENVIRONMENT FIRST. If in doubt
  65. do not use this module.
  66. This module has only been tested with MySQL and does not work with any other
  67. dbms. Assistance in adding support for other database systems would be
  68. appreciated, see the issue queue for further details.
  69. Make sure the PHP timeout is set high enough to complete a backup or restore
  70. operation. Larger databases require more time. Also, while the module attempts
  71. to keep memory needs to a minimum, a backup or restore will require
  72. significantly more memory than most Drupal operations.
  73. If the backup file contains the 'sessions' table all other users will be logged
  74. out after running a restore. To avoid this, exclude the sessions table when
  75. creating the backups. Be aware though that this table is still required to run
  76. Drupal, so it will need to be recreated if the backup is restored onto an empty
  77. database.
  78. Do not change the file extension of backup files or the restore function will be
  79. unable to determine the compression type of the file and will not function
  80. correctly.
  81. The module's permissions should only be given to trusted users due to the
  82. inherent security vulnerabilities in allowing people access to a site's database
  83. and/or files backups.
  84. If a restore fails
  85. -------------------------------------------------------------------------------
  86. Don't panic!
  87. The restore file should still work with phpMyAdmin's import function or with
  88. the mysql command line tool.
  89. If the backup does not restore using either a graphical tool or the command line
  90. tools, then it is likely corrupt; you may panic now.
  91. MAKE SURE THAT THIS MODULE IS NOT THE ONLY FORM OF BACKUP.
  92. Known problems and workarounds
  93. -------------------------------------------------------------------------------
  94. * If backups fail due to an out-of-memory, try adjusting the memory limit using
  95. the "backup_migrate_memory_limit" variable by adding one of these lines
  96. to the site's settings.php file:
  97. // Backup & Migrate: Use 512MB when generating backups.
  98. $conf['backup_migrate_memory_limit'] = '512M';
  99. // Backup & Migrate: Use 1GB when generating backups.
  100. $conf['backup_migrate_memory_limit'] = '1G';
  101. * If backups fail due to a PHP timeout error, especially an error saying "MySQL
  102. server has gone away", use the "backup_migrate_backup_max_time" variable to
  103. adjust the timeout. Before doing this, check to see what PHP's
  104. "max_execution_time" is set to, then set the "backup_migrate_backup_max_time"
  105. variable to a higher number, e.g. if max_execution_time is 180 (seconds) try
  106. setting backup_migrate_backup_max_time to 240 seconds / 4 minutes, or 300
  107. seconds / 5 minutes
  108. // Backup & Migrate: Adjust the PHP timeout to 5 minutes / 300 seconds.
  109. $conf['backup_migrate_backup_max_time'] = 300;
  110. * A variable has been added which may help with problems. Setting the variable
  111. 'backup_migrate_verbose' to TRUE will make the module log additional messages
  112. to watchdog as the module performs certain actions.
  113. // Backup & Migrate: Log extra messages as the module is working.
  114. $conf['backup_migrate_verbose'] = TRUE;
  115. * It can be frustrating working from a production database backup on non-prod
  116. servers as schduled backups will automatically run via cron the same as they
  117. run on production. The custom cron tasks may be disabled using the
  118. "backup_migrate_disable_cron" variable. Note: this doesn't prevent people
  119. from manually running backups via the UI or from the Drush commands, so it is
  120. safe to hardcode to TRUE on all site instances and then hardcode to FALSE on
  121. production environments.
  122. // Backup & Migrate: Don't run backups via cron.
  123. $conf['backup_migrate_disable_cron'] = TRUE;
  124. * There are three different variables that control how MySQL data is processed.
  125. Should a site have problems with memory limits, it is worth testing these to
  126. see which ones work the best.
  127. - backup_migrate_data_rows_per_query
  128. Controls how many records are loaded from the database at once. Defaults to
  129. "1000", i.e. 1,000 rows. Note that setting this to a high number can cause
  130. problems when exporting large data sets, e.g. cache tables can have huge
  131. volumes of data per record.
  132. // Backup & Migrate: Load 10,000 rows at once.
  133. $conf['backup_migrate_data_rows_per_query'] = 10000;
  134. - backup_migrate_data_rows_per_line
  135. Controls how many records are included in a single INSERT statement.
  136. Defaults to "30", i.e. 30 records.
  137. // Backup & Migrate: Combine no more than five records in a single row.
  138. $conf['backup_migrate_data_rows_per_line'] = 5;
  139. - backup_migrate_data_bytes_per_line
  140. Controls how much data will be inserted at once using a single INSERT
  141. statement. This works with the "backup_migrate_data_rows_per_line" variable
  142. to ensure that each INSERT statement doesn't end up being too large.
  143. Defaults to "2000", i.e. 2,000 bytes.
  144. // Backup & Migrate: Limit the output to 1000 bytes at a time.
  145. $conf['backup_migrate_data_bytes_per_line'] = 1000;
  146. Development notes
  147. --------------------------------------------------------------------------------
  148. It is worth noting that some of the tests will fail when ran against nginx,
  149. which is the default web server for some local development systems. As a result,
  150. it is recommended to run tests on a server that uses Apache HTTPd Server instead
  151. of nginx.
  152. Credits / contact
  153. --------------------------------------------------------------------------------
  154. Currently maintained by Alex Andrascu [1], Damien McKenna [2] and
  155. Daniel Pickering [3]. All original development up through 2015 was by
  156. Ronan Dowling [4] with help by Drew Gorton [5].
  157. The best way to contact the authors is to submit an issue, be it a support
  158. request, a feature request or a bug report, in the project issue queue:
  159. https://www.drupal.org/project/issues/backup_migrate
  160. References
  161. --------------------------------------------------------------------------------
  162. 1: https://www.drupal.org/u/alex-andrascu
  163. 2: https://www.drupal.org/u/damienmckenna
  164. 3: https://www.drupal.org/u/ikit-claw
  165. 4: https://www.drupal.org/u/ronan
  166. 5: https://www.drupal.org/u/dgorton