Download Files from Your Compute Instance
Traducciones al EspañolEstamos traduciendo nuestros guías y tutoriales al Español. Es posible que usted esté viendo una traducción generada automáticamente. Estamos trabajando con traductores profesionales para verificar las traducciones de nuestro sitio web. Este proyecto es un trabajo en curso.
Periodically, you may wish to download files from a Compute Instance to retain as a local backup or work on them locally. This guide covers the techniques and tools you can use to download your remote files to your local machine.
If you intend to download lots of files, consider compressing them into a single archive file before continuing with this guide. This results in a faster and smoother download when compared with large numbers of individual files. Once the archive file has been downloaded, you can extract it and view the individual files on your local system.
To create an archive and compress it, log in to your Compute Instance and run the following command. Replace [archive-name] with the file name to use for the new file and [file-or-directory] with the path of the directory or the path and name of the file you’d like to archive. This command creates a tar file (also called a tarball) and compresses it with gzip. Most modern operating systems can extract tar files.
tar -czvf [archive-name].tar.gz [fle-or-directory]
For example, to archive all of website data stored in
/var/www/example.com to a file called
example-com-backup in my home directory, the following command would be used:
tar -czvf ~/example-com-backup.tar.gz /var/www/example.com/
To learn more about creating tar files, see Archive, Compress, and Extract Files in Linux Using the Command Line.
SFTP (Secure File Transfer Protocol) is a common method of transferring files from a remote system to a local machine. It is often referred to as FTP, though SFTP is built using an entirely new protocol. For this guide, FTP and SFTP are used interchangeably unless otherwise noted.
FTP clients are a user-friendly way to access, download, and upload files from your Compute Instance. Many desktop FTP clients are available, including:
- FileZilla: A free and open-source FTP client for Windows, macOS, and Linux.
- WinSCP: A free and open-source FTP client for Windows.
- Transmit: A paid FTP client for macOS.
- ForkLift: A file manager and FTP client for macOS.
Whichever client you choose, you can connect to your Compute Instance using the same credentials you would use for SSH. Once connected, you should be presented with a visual file explorer of your remote system. From here, you can navigate to the directory where your files are located and then download those files.
For further instructions, see our Transfer Files with FileZilla guide.
You can use SCP (Secure Copy Protocol) to retrieve a specific directory or file via the command-line. SCP is installed by default on most macOS and Linux systems and is available with Cygwin or PuTTY for Windows.
The syntax for using SCP to copy a file from your Linode into a directory on another computer is:
scp [user]@[ip-address]:[file] /path/to/your/local/directory/
The file will be saved inside
To copy a file from your Linode to another computer and give it a specific name (in this case,
scp your_linode_username@your_linode_ip:/path/to/your/file.txt /path/to/your/local/directory/file.txt.backup
To copy an entire directory:
scp -r your_linode_username@your_linode_ip:/path/to/your/directory /path/to/your/local/directory
/path/to/your/local/directoryalready exists on your computer, then the copied directory will be placed inside
/path/to/your/local/directorydoes not already exist, then the copied directory will be created with that name.
Download an NGINX configuration file to your user’s
scp your_linode_username@your_linode_ip:/etc/nginx/conf.d/example.com.conf ~/example.com.conf.backup
Download an Apache configuration file to your
scp your_linode_username@your_linode_ip:/etc/apache2/sites-available/example.com.conf ~/example.com.conf.backup
Copy the entire document root from a web server:
scp -r your_linode_username@your_linode_ip:/var/www/html/ ~/html_backup
If you intend to repeat this process regularly, consider using rsync to create additional local copies of your data. rsync is capable of performing incremental file copies, which means you do not have to fully transfer each file every time you download your data.
Special care is needed when downloading data from a database. Before it can be downloaded, the data in a database needs to first be dumped to a file. This database dump file can then be transferred just as any other normal file type.
To create a dump of a MySQL (or MariaDB) database, use the
mysqldumpcommand. You can only use this tool if your database process is accessible and running.
If your MySQL database won’t run for some reason, follow the instructions for creating physical backups.
If you use PostgreSQL, follow the How to Back Up Your PostgreSQL Database guide.
Downloading your disk will copy a
.img file to your computer that encapsulates all of the data that is on your Linode’s disk. This disk image can later be re-uploaded to the Linode service at a later date, which can be useful if you’d like to temporarily remove your Linode and stop service. Follow our Copy a Disk over SSH guide for further instructions.
This page was originally published on