Quickly Backup a Site Through FTP with wget

Apr 4, 2011 - 4 Comments

If you want to quickly backup an entire website through FTP, the absolute easiest way to do this is through the command line using the wget command.

The syntax we’ll use is as follows:

wget -r ftp://username:password@domain.com/

Change the username and password to the appropriate login information, and change the domain to the site you wish to mirror/backup. If you’re curious, the -r flag just stands for recursive.

The entire website will be backed up locally in the directory the wget command was ran from, to prevent any potential clutter you may want to make a quick directory using mkdir and run wget from there, particularly if you’re working with very large web sites.

We’ve used wget to mirror a website locally before, it’s a powerful tool and is a worthwhile install if you’re an advanced user and don’t have it on your Mac already. Installing wget requires you to install something like XCode, HomeBrew, or MacPorts first, each of which also gives you access to thousands of other command line tools either through compiling source or prepackaged binaries.

Enjoy this tip? Subscribe to the OSXDaily newsletter to get more of our great Apple tips, tricks, and important news delivered to your inbox! Enter your email address below:

Related articles:

Posted by: David Mendez in Command Line, Tips & Tricks

4 Comments

» Comments RSS Feed

  1. Loren says:

    I find wget more reliable than a GUI client any day

  2. copper says:

    hey this is really handy I like it!

  3. lkuty says:

    I find the following useful.

    wget -r -nH –cut-dirs=5 -nc ftp://user:pass@server//absolute/path/to/directory

    Note the double slash after the server name. If I don’t put an extra slash the path is relative to the home directory of user.

    -nH avoids the creation of a directory named after the server name
    -nc avoids creating a new file if it already exists on the destination (it is just skipped)
    –cut-dirs=5 allows me to take the content of /absolute/path/to/directory and to put it in the directory where I launch wget. The number 5 is used to filter out the 5 components of the path. The double slash means an extra component.

Leave a Reply

 

Shop for Apple & Mac Deals on Amazon.com

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates