Website backup


wget -xkrNE -nH {url} -P /path/to/target/folder/
wget -xkrNE -nH -P /var/www/html/ce/
  • -k after the download is complete, convert the links in the document to make them suitable for local viewing
  • -x create a hierarchy of directories
  • -r recursive
  • -N if the local file has the same timestamp as the server, or a newer one, the remote file will not be re-fetched
  • -E aka --adjust-extension will change the file extension to .html or .css or .xml if the file-type suggests it
  • -nH disable generation of host-prefixed directories
  • -P /path/to/target/folder/ will create target folder is non-existent

The -E option is useful to bypass problems related to .css when there is a ?ver=… at the end.

If you download a Wordpress site, don’t forget to delete the file wp-login.php in the root directory. This file will still point to the source loction.

Note to self… investigate:

  • –no-parent