Report this

What is the reason for this report?

how to back-up public_html (only) in my server to a remote server

Posted on May 13, 2015

hi, i would like to know if there’s a way to back-up my public_html directory only to a remote server. note: i don’t want to create a snapshot. only my public_html. if there’s an external service that would be cool



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Compress the whole directory and transfer it to another server using SCP.

cd /var/backups
export FILE_DATE=`date +%Y%m%d-%H.%M.%S`
tar -czf public_html-$FILE_DATE.tar.gz /location/to/public_html
scp public_html-$FILE_DATE.tar.gz username@remote.server.ip:/remote/directory
unset FILE_DATE

To back up your public_html directory to a remote server, you have several options. Here are a few methods you can consider:

  1. Rsync:
  • Rsync is a very efficient file copying tool that can synchronize files and directories between two locations over a network.
  • You can use Rsync to back up your public_html directory to a remote server by running a command like:
rsync -avz --progress /path/to/public_html user@remote_server:/path/to/backup/
  • The -avz options are for archive mode, verbose, and compression, respectively, and --progress shows the progress of the transfer.
  1. SCP (Secure Copy Protocol):
  • SCP is a means of securely transferring computer files between a local host and a remote host or between two remote hosts.
  • A simple SCP command to back up your public_html directory would be:
scp -r /path/to/public_html user@remote_server:/path/to/backup/
  • The -r option is for recursive copying to include subdirectories.
  1. FTP/SFTP Client:

    • For non-command line options, you can use an FTP (File Transfer Protocol) or SFTP (SSH File Transfer Protocol) client like FileZilla or WinSCP.
    • These clients provide a graphical interface to transfer your files from your local machine to a remote server securely.
  2. Cloud Storage Services:

    • Cloud storage services like Amazon S3, Google Cloud Storage, or Dropbox can be used to store your backups.
    • These services often provide tools or APIs to automate the backup process, and you can set up a script to sync your public_html directory regularly.
  3. Web Hosting Control Panels:

    • If you have a web hosting control panel like cPanel, it often comes with built-in backup functionalities.
    • You can use the backup feature to select the public_html directory and set a remote FTP or SCP destination for the backup.
  4. Backup Services:

    • There are also dedicated backup services like CodeGuard, Dropmysite, or BackupMachine that can automatically back up your website’s content to the cloud.
  5. Custom Scripts:

    • You can write custom bash scripts to automate the backup process using one of the above methods, which can be run via cron jobs for regular backups.

Before you proceed with any of these options, ensure that you have the necessary permissions to access both the local public_html directory and the remote server. Also, consider the security implications of transferring sensitive data and encrypt your backups if possible.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.