Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 0 additions & 45 deletions docs/databases/mysql/mysqldump-database-backup-short/index.md

This file was deleted.

33 changes: 0 additions & 33 deletions docs/databases/mysql/mysqldump-database-restore-short/index.md

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,34 @@ The instructions in this guide apply to both MySQL and MariaDB. For simplificati

## Back up a Database

{{< content "mysqldump-database-backup-short" >}}
The `mysqldump` command’s general syntax is:

mysqldump -u [username] -p [databaseName] > [filename]-$(date +%F).sql

* `mysqldump` prompts for a password before it starts the backup process.
* Depending on the size of the database, it could take a while to complete.
* The database backup will be created in the directory the command is run.
* `-$(date +%F)` adds a timestamp to the filename.

Example use cases include:

* Create a backup of an entire Database Management System (DBMS):

mysqldump --all-databases --single-transaction --quick --lock-tables=false > full-backup-$(date +%F).sql -u root -p

* Back up a specific database. Replace `db1` with the name of the database you want to back up:

mysqldump -u username -p db1 --single-transaction --quick --lock-tables=false > db1-backup-$(date +%F).sql

* Back up a single table from any database. In the example below, `table1` is exported from the database `db1`:

mysqldump -u username -p --single-transaction --quick --lock-tables=false db1 table1 > db1-table1-$(date +%F).sql

Here's a breakdown of the `mysqldump` command options used above:

- `--single-transaction`: Issue a BEGIN SQL statement before dumping data from the server.
- `--quick`: Enforce dumping tables row by row. This provides added safety for systems with little RAM and/or large databases where storing tables in memory could become problematic.
- `--lock-tables=false`: Do not lock tables for the backup session.

## Automate Backups with cron

Expand Down Expand Up @@ -61,4 +88,19 @@ password = MySQL root user's password

## Restore a Backup

{{< content "mysqldump-database-restore-short" >}}
The restoration command's general syntax is:

mysql -u [username] -p [databaseName] < [filename].sql

* Restore an entire DBMS backup. You will be prompted for the MySQL root user's password:\
**This will overwrite all current data in the MySQL database system**

mysql -u root -p < full-backup.sql

* Restore a single database dump. An empty or old destination database must already exist to import the data into, and the MySQL user you're running the command as must have write access to that database:

mysql -u [username] -p db1 < db1-backup.sql

* Restore a single table, you must have a destination database ready to receive the data:

mysql -u dbadmin -p db1 < db1-table1.sql
2 changes: 1 addition & 1 deletion docs/networking/ssh/using-ssh-on-windows/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ published: 2009-09-20
title: Using SSH on Windows
---

<!-- ![Using PuTTY](using-putty.png "Using PuTTY")-->
![Using SSH on Windows](using-ssh-on-windows.png "Using SSH on Windows")

## OpenSSH
As of late 2018, [OpenSSH](https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_overview) is included with some versions of Windows.
Expand Down
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
81 changes: 0 additions & 81 deletions docs/platform/disk-images/copy-disk-over-ssh-short/index.md

This file was deleted.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
71 changes: 69 additions & 2 deletions docs/platform/disk-images/copying-a-disk-image-over-ssh/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,80 @@ published: 2012-06-04
title: "Copy a Disk Over SSH"
---

<!-- ![Copy a Disk Over SSH](copying_a_disk_over_ssh_smg.png "Copy a Disk Over SSH")-->
![Copy a Disk Over SSH](copying_a_disk_over_ssh_smg.png "Copy a Disk Over SSH")

Piping SSH commands to utilities such as `dd`, `gzip`, or `rsync` is an easy way to copy a Linode's data into a single file for later extraction. This can effectively back up your Linode's disk or migrate your installed system among Linodes.

This guide demonstrates how to download a `.img` file to your computer over SSH containing a block-level copy of your Linode's disk device created with `dd`.

{{< content "copy-disk-over-ssh-short" >}}
## Download a Disk over SSH

### Boot into Rescue Mode

1. Prepare the receiving computer by verifying that SSH is installed. Most Linux/Unix-like systems include OpenSSH in their package base by default. If the receiving system is Microsoft Windows, there are multiple SSH solutions available such as [Cygwin and PuTTY](/docs/networking/ssh/using-ssh-on-windows).

1. Reboot Your Linode into [rescue mode](/docs/troubleshooting/rescue-and-rebuild/#booting-into-rescue-mode) and connect to it using [Lish](/docs/platform/manager/remote-access/#console-access).

1. Set a root password for the rescue system and start the SSH server:

passwd
service ssh start

### Copy and Download the Disk

1. Copy the disk over SSH from the Linode to the receiving machine. Replace `192.0.2.9` with the Linode's IP address and `/home/archive/linode.img` with the path where you want to store the disk.

ssh root@192.0.2.9 "dd if=/dev/sda " | dd of=/home/archive/linode.img

{{< note >}}
The device `/dev/sda` is used for Linodes running on KVM. If your Linode is still using XEN, then use `/dev/xvda` throughout this guide instead.
{{< /note >}}

1. The receiving machine will connect to the Linode. Verify the SSH key fingerprints. If valid, type `yes` and press **Enter** to continue:

The authenticity of host '192.0.2.9 (192.0.2.9)' can't be established.
RSA key fingerprint is 39:6b:eb:05:f1:28:95:f0:da:63:17:9e:6b:6b:11:4a.
Are you sure you want to continue connecting (yes/no)? yes

1. Enter the root password you created above for the rescue system:

Warning: Permanently added '192.0.2.9' (RSA) to the list of known hosts.
root@192.0.2.9's password:

When the transfer completes, you'll see a summary output similar to below:

{{< output >}}
4096000+0 records in
4096000+0 records out
2097152000 bytes (2.1 GB) copied, 371.632 seconds, 5.6 MB/s
{{</ output >}}

Copying your disk can take a while. If you have a slow internet connection, add the `-C` option to the SSH command to enable gzip compression of the disk image. If you receive a `Write failed: Broken pipe` error, repeat this process.

### Verify the Disk

Once the copy has completed, verify it by mounting the image on the receiving machine.

1. Switch users to `root` on receiving machine:

su

1. Make a directory to mount the disk as:

mkdir linode

1. Mount the disk. Replace `linode.img` with the name of the of your Linode's disk.

mount -o loop linode.img linode

1. List the directories on the disk to indicate if everything has transferred. Your output of `ls` is similar to below:

ls linode

{{< output >}}
bin dev home lost+found mnt proc sbin srv tmp var
boot etc lib media opt root selinux sys usr
{{< /output >}}

## Upload a Disk over SSH

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ The [Linode Backups](/docs/platform/disk-images/linode-backup-service/) service

Linode's backups are stored in a way that is only directly readable by the Linode Backups service. A common question for the service is how you can download the content from your Linode Backups to another storage location, like your home computer. This can be accomplished in two phases:

1. Restore a backup to a new or existing Linode.
2. Download either specific files or the entire disk image from that Linode, as needed.
1. [Restore a backup](#restore-from-a-backup) to a new or existing Linode.
2. Download either [specific files](#download-specific-files-or-directories-over-ssh) or the [entire disk image](#download-a-disk-over-ssh) from that Linode, as needed.

## Before You Begin

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ title: Download Files from your Linode - Shortguide
headless: true
---

## Secure Copy Protocol (SCP)
## Download Specific Files or Directories over SSH

If you just need specific files from your Linode, you can download those over SSH. Downloading files over SSH can be done at a command-line interface, or with a graphical *SFTP* file browser.

### Secure Copy Protocol (SCP)

You can use SCP 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](/docs/networking/ssh/using-ssh-on-windows) for Windows.

Expand Down Expand Up @@ -51,23 +55,22 @@ For example:

If you intend to repeat this process regularly, consider [using rsync](/docs/security/backups/backing-up-your-data/#understand-the-rsync-command) 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.


## FileZilla
### FileZilla

FileZilla is a popular free and open source FTP, FTPS, and SFTP client which has a GUI but can also take CLI arguments. In contrast to to SCP, SFTP can list directory contents, create or delete files, and resume interrupted file transfers.

See our [FileZilla guide](http://localhost:1313/docs/tools-reference/file-transfer/filezilla/) for more information.

## Downloading Data from a Database
### Downloading Data from a Database

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.

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 file can then be transferred just as any other normal file type.
- To create a dump of a MySQL (or MariaDB) database, [use the `mysqldump` command](/docs/databases/mysql/use-mysqldump-to-back-up-mysql-or-mariadb). **You can only use this tool if your database process is accessible and running.**

To create a dump of a MySQL (or MariaDB) database, [use the `mysqldump` command](/docs/databases/mysql/use-mysqldump-to-back-up-mysql-or-mariadb) as in the following instructions. **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](/docs/databases/mysql/create-physical-backups-of-your-mariadb-or-mysql-databases/).

{{< note >}}
An alternative to using `mysqldump` is to create [*physical* backups](/docs/databases/mysql/create-physical-backups-of-your-mariadb-or-mysql-databases/). If you use PostgreSQL, follow the [How to Back Up Your PostgreSQL Database](/docs/databases/postgresql/how-to-back-up-your-postgresql-database/) guide instead.
{{< /note >}}
- If you use PostgreSQL, follow the [How to Back Up Your PostgreSQL Database](/docs/databases/postgresql/how-to-back-up-your-postgresql-database/) guide.

{{< content "mysqldump-database-backup-short" >}}
## Download a Disk over SSH

{{< content "copy-disk-over-ssh-short" >}}
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](/docs/platform/disk-images/copying-a-disk-image-over-ssh/) guide for further instructions.
Loading