Skip to content
Nexcess.com Servers.com LiquidWeb.com
Search our site for answers
Login
  • Help Docs
  • API Docs
  • liquidweb.com
  • Hosting Services
    • Cloud VPS Hosting
    • Dedicated Servers
    • GPU Hosting
    • Hosting For WordPress
    • Hosting For WooCommerce
    • Email Hosting
    • VMware Hosting
    • Add-ons
  • Security & Compliance
    • SSL Certificates
    • Firewalls
    • Cloud Hosting
    • Two Factor Authentication
    • DDoS Protection
    • Compliance
    • Malware Protection
  • Domain & DNS
    • Domain Registration
    • DNS Settings
    • Nameservers
    • Subdomains
    • Domain Forwarding
    • Email DNS Setup
  • Account & Billing
    • Account Setup
    • Payment Methods
    • Billing Cycles
    • Refunds Cancellations
    • Invoices Receipts
    • Account Security
  • Email Hosting
    • Email Setup
    • Email Forwarding
    • Spam Protection
    • Microsoft 365
    • G Suite Setup
    • Account Security
    • Email Troubleshooting
  • Performance & Optimization
    • Server Optimization
    • Caching Strategies
    • Content Delivery Network
    • Database Performance
    • Image Optimization
  • Server Administration
    • Server Setup
    • SSH Access
    • Command Line Basics
    • Database Management
    • CRON Jobs
    • Apache Nginx Setup
    • Log Analysis
  • CMS & Applications
    • WordPress
    • WooCommerce
    • Magento
    • Joomla
    • Drupal
  • Backups & Recovery
    • Backup Strategies
    • Cloud Backups
    • Disaster Recovery
    • Restoring Backups
    • Raid Configurations
  • Reseller & Partner Support
    • Reseller Program
    • White Label Hosting
    • Partner Portal
    • Client Management
  • Policies & Compliance
    • Terms Of Service
    • Privacy Policy
    • GDPR Compliance
    • Acceptable Use Policy
Help Docs Server Administration Server Backup and Restore Using SSH to Backup Files

Using SSH to Backup Files

Backups can be set up via cPanel, WHM, or Liquid Web account for entire server. For specific files, use CLI via SSH, but be cautious as root user can alter/delete anything without confirmation.
Account
3 min read

Backups can be set up via cPanel, WHM and in your Liquid Web account for your entire server, but if you’re looking to backup specific files you’ve created you will need to use the Command Line Interface (CLI) via SSH. If you’ve never logged in via SSH, learn how in our article Logging into Your Server via Secure Shell (SSH).

Warning:

Logging into a server as root is a powerful but potentially dangerous tool. The root user is allowed to change/delete practically everything in a server without warning or confirmation of changes being made.

  1. Once you’ve logged in via SSH, enter the following command to view all the files on your server:
    ls -lah
  2. This will list all the files in human-readable format. From here, you can choose the files you want to backup.
    total 176K
    dr-xr-x---. 13 root root 4.0K Sep 28 10:34 .
    dr-xr-xr-x. 19 root root 4.0K Aug 8 10:29 ..
    1 root root 35 Sep 28 10:34 anothersample.txt
    1 root root 2.4K Sep 28 10:35              .bash_history
    -rw-r--r--. 1 root root18 Dec 28 2013      .bash_logout
    -rw-r--r--. 1 root root 176 Dec 28 2013    .bash_profile
    1 root root 360 May 3 12:40 .bashrc
    drwx------  4 root root 4.0K May 3 12:01   .cpanel
    drwxr-xr-x  4 root root 4.0K Jun 1 15:53    cpanel3-skel 
    -rw-r--r--. 1 root root 100 Dec 28 2013    .cshrc 
    -rw-------  1 root root 1 May 3 12:01      .forward 
    drwx------  2 root root 4.0K May 3 11:35   .gnupg 
    drwx------  2 root root 4.0K May 25 15:26  .HttpRequest 
    drwx------  4 root root 4.0K May 25 15:26  .MirrorSearch 
    -rw-------  1 root root 42 May 25 15:16 .my.cnf 
    drwxr-xr-x  2 root root 4.0K Jun 20 14:51 perl5 
    -rw-r--r--  1 root root 39K May 3 12:15 php.ini.new 
    -rw-r--r--  1 root root 39K May 3 12:15 php.ini.orig 
    drwxr----- 3 root root 4.0K May 3 12:17    .pki 
    drwxr-xr-x  2 root root 4.0K Sep 28 09:51  .razor 
    -rw------- 1 root root 1.0K May 3 11:43    .rnd 
    -rw-r--r--  1 root root 84 Sep 28 10:34 sample.txt 
    drwx------  3 root root 4.0K May 3 11:41   .spamassassin 
    drw-------  2 root root 4.0K Aug 4 14:47   .ssh 
    -rw-r--r--. 1 root root 129 Dec 28 2013    .tcshrc 
    drwxr-xr-x  3 root root 4.0K Sep 27 22:58   tmp
  3. In this example, I will backup the file sample.txt. In order to backup the file, type the following command:
    cp sample.txt sample.bak
  4. This copies the file sample.txt and creates a new file called sample.bak. Another use of the ls -lah command will show you the new file:
    total 180K 
    dr-xr-x---. 13 root root 4.0K Sep 28 10:39 . 
    dr-xr-xr-x. 19 root root 4.0K Aug 8 10:29 .. 
    -rw-r--r-- 1 root root 35 Sep 28 10:34 anothersample.txt 
    -rw------- 1 root root 2.4K Sep 28 10:35 .bash_history 
    -rw-r--r--. 1 root root 18 Dec 28 2013 .bash_logout 
    -rw-r--r--. 1 root root 176 Dec 28 2013 .bash_profile 
    -rw-r--r--. 1 root root 360 May 3 12:40 .bashrc 
    drwx------ 4 root root 4.0K May 3 12:01 .cpanel 
    drwxr-xr-x 4 root root 4.0K Jun 1 15:53 cpanel3-skel 
    -rw-r--r--. 1 root root 100 Dec 28 2013 .cshrc 
    -rw------- 1 root root 1 May 3 12:01 .forward 
    drwx------ 2 root root 4.0K May 3 11:35 .gnupg 
    drwx------ 2 root root 4.0K May 25 15:26 
    .HttpRequest drwx------ 4 root root 4.0K May 25 15:26 .MirrorSearch 
    -rw------- 1 root root 42 May 25 15:16 .my.cnf 
    drwxr-xr-x 2 root root 4.0K Jun 20 14:51 perl5 
    -rw-r--r-- 1 root root 39K May 3 12:15 php.ini.new 
    -rw-r--r-- 1 root root 39K May 3 12:15 php.ini.orig 
    drwxr----- 3 root root 4.0K May 3 12:17 .pki 
    drwxr-xr-x 2 root root 4.0K Sep 28 09:51 .razor 
    -rw------- 1 root root 1.0K May 3 11:43 .rnd 
    -rw-r--r-- 1 root root 84 Sep 28 10:39 sample.bak 
    -rw-r--r-- 1 root root 84 Sep 28 10:34 sample.txt 
    drwx------ 3 root root 4.0K May 3 11:41 .spamassassin 
    drw------- 2 root root 4.0K Aug 4 14:47 .ssh 
    -rw-r--r--.1 root root 129 Dec 28 2013 .tcshrc 
    drwxr-xr-x 3 root root 4.0K Sep 27 22:58 tmp

If you need to backup more than one file or need to backup full directories, see our article Exploring the rsync Utility.

Was this article helpful?
Thank you for your input.
Thank you for your feedback.
Get hosting news and tips straight to your inbox
Join our community today.
Loading form…
Essential hosting resources to help your business stay ahead
Get the guides

Solutions

Managed Dedicated Cloud Dedicated Managed VPS WordPress Managed Managed Magento Managed WooCommerce Signature Services Add-ons

Company

Contact About Terms of Service Privacy Policy Customer Stories Global Cloud Platform

Resources

Help Docs Resource Center Web Hosting Tools Sitemap

Partnerships

Hosting Affiliate Program Partner Programs Refer-a-Friend
HostingAdvice.com logo
Liquid Web review Liquid Web review

©  Liquid Web, LLC by Nexcess Corp.

Privacy Policy

  • Solutions
  • VPS Hosting
  • Dedicated Servers
  • Managed Hosting
  • WordPress
  • GPU Hosting
  • Products
Log in
  • System status
  • Support | Get Help