<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: SimpleBackups</title>
    <description>The latest articles on DEV Community by SimpleBackups (@simplebackups).</description>
    <link>https://dev.to/simplebackups</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Forganization%2Fprofile_image%2F2529%2F5d0c8e3b-7ebc-41c6-bda8-7a65cead011e.png</url>
      <title>DEV Community: SimpleBackups</title>
      <link>https://dev.to/simplebackups</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/simplebackups"/>
    <language>en</language>
    <item>
      <title>Restore or Migrate your MySQL Database to Railway</title>
      <dc:creator>Nour</dc:creator>
      <pubDate>Fri, 03 Nov 2023 14:42:08 +0000</pubDate>
      <link>https://dev.to/simplebackups/restore-or-migrate-your-mysql-database-to-railway-4183</link>
      <guid>https://dev.to/simplebackups/restore-or-migrate-your-mysql-database-to-railway-4183</guid>
      <description>&lt;p&gt;&lt;a href="https://railway.app" rel="noopener noreferrer"&gt;Railway&lt;/a&gt; is a serverless platform that makes it easy to deploy and manage applications and databases. It offers a variety of features, including automatic scaling, high availability, and support for a variety of programming languages and frameworks.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/Hrvi_BSYswo"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  How to Create a Railway MySQL Database
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Navigate to the &lt;a href="https://railway.app/" rel="noopener noreferrer"&gt;Railway Website&lt;/a&gt; and click on "Start new project".&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fsimplerestore.io%2Fassets%2Fposts%2Frestore-your-mysql-database-to-railway%2Frailway-start-new-project.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fsimplerestore.io%2Fassets%2Fposts%2Frestore-your-mysql-database-to-railway%2Frailway-start-new-project.png" title="Railway Website" alt="Railway Website"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You'll see a prompt asking you what type of project you want to create, type in MySQL and select "Provision MySQL" from the list. &lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fsimplerestore.io%2Fassets%2Fposts%2Frestore-your-mysql-database-to-railway%2Frailway-project-select.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fsimplerestore.io%2Fassets%2Fposts%2Frestore-your-mysql-database-to-railway%2Frailway-project-select.png" title="Railway Project prompt" alt="Railway Project prompt"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Once the database is provisioned, click on it &lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fsimplerestore.io%2Fassets%2Fposts%2Frestore-your-mysql-database-to-railway%2Frailway-db-ready.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fsimplerestore.io%2Fassets%2Fposts%2Frestore-your-mysql-database-to-railway%2Frailway-db-ready.png" title="Railway project grid" alt="Railway project grid"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click on "Connect" &lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fsimplerestore.io%2Fassets%2Fposts%2Frestore-your-mysql-database-to-railway%2Frailway-connect-tab.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fsimplerestore.io%2Fassets%2Fposts%2Frestore-your-mysql-database-to-railway%2Frailway-connect-tab.png" title="Railway connect tab" alt="Railway connect tab"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Scroll down to the "Available Variables" section and take note of the MYSQL_URL (your connection string), as you'll need it later. &lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fsimplerestore.io%2Fassets%2Fposts%2Frestore-your-mysql-database-to-railway%2Frailway-available-variables.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fsimplerestore.io%2Fassets%2Fposts%2Frestore-your-mysql-database-to-railway%2Frailway-available-variables.png" title="Railway connection string" alt="Railway connection string"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  How to Restore a MySQL Dump to Railway.app using SimpleRestore.io
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://simplerestore.io" rel="noopener noreferrer"&gt;SimpleRestore.io&lt;/a&gt; is a user-friendly tool that simplifies the process of restoring a MySQL database. Follow these steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Visit &lt;a href="https://simplerestore.io" rel="noopener noreferrer"&gt;SimpleRestore.io&lt;/a&gt; &lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fsimplerestore.io%2Fassets%2Fposts%2Frestore-your-mysql-database-on-planetscale%2Fsimplerestore-io-wizard.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fsimplerestore.io%2Fassets%2Fposts%2Frestore-your-mysql-database-on-planetscale%2Fsimplerestore-io-wizard.png" title="SimpleRestore.io" alt="SimpleRestore.io"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click on "Select your database backup (.tar.gz)" and select your backup archive.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enter your connection string that you noted down earlier.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click "Restore" and wait for the process to complete. &lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fsimplerestore.io%2Fassets%2Fposts%2Frestore-your-mysql-database-to-railway%2Fsimplerestore-logs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fsimplerestore.io%2Fassets%2Fposts%2Frestore-your-mysql-database-to-railway%2Fsimplerestore-logs.png" title="SimpleRestore.io" alt="SimpleRestore.io"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  (Bonus) How to Restore a Railway.app Dump on Your Local Database
&lt;/h2&gt;

&lt;p&gt;If you want to restore the dump to your local MySQL database, follow these steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Log in to your local MySQL server.&lt;/li&gt;
&lt;li&gt;Create a new database or select an existing one.&lt;/li&gt;
&lt;li&gt;Use the &lt;code&gt;mysql&lt;/code&gt; command to restore the dump:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mysql &lt;span class="nt"&gt;-u&lt;/span&gt; username &lt;span class="nt"&gt;-p&lt;/span&gt; database_name &amp;lt; dump_file.sql
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace &lt;code&gt;username&lt;/code&gt;, &lt;code&gt;database_name&lt;/code&gt;, and &lt;code&gt;dump_file.sql&lt;/code&gt; with your specific details.&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What is a MySQL Backup Service?
&lt;/h3&gt;

&lt;p&gt;A MySQL backup service is a tool or platform that allows you to create copies of your MySQL databases, ensuring data protection and recovery in case of unexpected events or data loss.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is a MySQL Connection String?
&lt;/h3&gt;

&lt;p&gt;A MySQL connection string is a string that contains the information needed to connect to a MySQL database. It typically includes details like the host, port, username, password, and database name.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is a MySQL Dump?
&lt;/h3&gt;

&lt;p&gt;A MySQL dump is a file that contains a SQL script with all the commands needed to recreate a database. It includes table structures and data.&lt;/p&gt;

&lt;h3&gt;
  
  
  How to Restore a MySQL Backup?
&lt;/h3&gt;

&lt;p&gt;To restore a MySQL backup, you need to have a dump file. You can use tools like SimpleRestore.io to easily upload and restore the backup to your desired database.&lt;/p&gt;

&lt;h3&gt;
  
  
  How to Create a MySQL Backup for Railway.app?
&lt;/h3&gt;

&lt;p&gt;You can create a MySQL backup for &lt;a href="https://railway.app" rel="noopener noreferrer"&gt;Railway.app&lt;/a&gt; using the &lt;a href="https://github.com/mydumper/mydumper" rel="noopener noreferrer"&gt;MyDumper tool&lt;/a&gt; or by using a backup service like &lt;a href="https://simplebackups.com" rel="noopener noreferrer"&gt;SimpleBackups&lt;/a&gt;. Both methods involve generating a dump file that can be used for restoration.&lt;/p&gt;

</description>
      <category>mysql</category>
      <category>database</category>
      <category>restore</category>
    </item>
    <item>
      <title>Restore your MySQL Database on PlanetScale</title>
      <dc:creator>Nour</dc:creator>
      <pubDate>Fri, 03 Nov 2023 14:41:45 +0000</pubDate>
      <link>https://dev.to/simplebackups/restore-your-mysql-database-on-planetscale-44fk</link>
      <guid>https://dev.to/simplebackups/restore-your-mysql-database-on-planetscale-44fk</guid>
      <description>&lt;p&gt;&lt;a href="https://planetscale.com/" rel="noopener noreferrer"&gt;PlanetScale&lt;/a&gt; offers a cloud-native, serverless, and multi-cloud MySQL database service. It's designed to provide high availability, scalability, and simplicity for your database needs. With features like automatic sharding, you can scale your database effortlessly.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/2zU_9wd209o"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  How to Create a PlanetScale MySQL Database
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Sign in to your PlanetScale account and navigate to the dashboard.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fsimplerestore.io%2Fassets%2Fposts%2Frestore-your-mysql-database-on-planetscale%2Fplanetscale-create-db.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fsimplerestore.io%2Fassets%2Fposts%2Frestore-your-mysql-database-on-planetscale%2Fplanetscale-create-db.png" title="PlanetScale Dashboard" alt="PlanetScale Dashboard"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click on "Create Database" and follow the prompts to set up your database.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;When you're done, you'll be redirected to a page where you can create a new password, in order to grab your connection string, select "Rust" or "Prisma" as your framework or programming language.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fsimplerestore.io%2Fassets%2Fposts%2Frestore-your-mysql-database-on-planetscale%2Fplanetscale-select-langauge.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fsimplerestore.io%2Fassets%2Fposts%2Frestore-your-mysql-database-on-planetscale%2Fplanetscale-select-langauge.png" title="PlanetScale password creation" alt="PlanetScale password creation"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Take note of your database connection string, as you'll need it later.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  How to Restore a PlanetScale Dump on a Remote Database using SimpleRestore.io
&lt;/h2&gt;

&lt;p&gt;SimpleRestore.io is a user-friendly tool that simplifies the process of restoring a MySQL database. Follow these steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Visit &lt;a href="https://simplerestore.io" rel="noopener noreferrer"&gt;SimpleRestore.io&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fsimplerestore.io%2Fassets%2Fposts%2Frestore-your-mysql-database-on-planetscale%2Fsimplerestore-io-wizard.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fsimplerestore.io%2Fassets%2Fposts%2Frestore-your-mysql-database-on-planetscale%2Fsimplerestore-io-wizard.png" title="SimpleRestore.io" alt="SimpleRestore.io"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click on "Select your database backup (.tar.gz)" and select your backup archive.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enter your connection string that you noted down earlier.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click "Restore" and wait for the process to complete.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  (Bonus) How to Restore a PlanetScale Dump on Your Local Database
&lt;/h2&gt;

&lt;p&gt;If you want to restore the dump to your local MySQL database, follow these steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Log in to your local MySQL server.&lt;/li&gt;
&lt;li&gt;Create a new database or select an existing one.&lt;/li&gt;
&lt;li&gt;Use the &lt;code&gt;mysql&lt;/code&gt; command to restore the dump:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mysql &lt;span class="nt"&gt;-u&lt;/span&gt; username &lt;span class="nt"&gt;-p&lt;/span&gt; database_name &amp;lt; dump_file.sql
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace &lt;code&gt;username&lt;/code&gt;, &lt;code&gt;database_name&lt;/code&gt;, and &lt;code&gt;dump_file.sql&lt;/code&gt; with your specific details.&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What is a MySQL Backup Service?
&lt;/h3&gt;

&lt;p&gt;A MySQL backup service is a tool or platform that allows you to create copies of your MySQL databases, ensuring data protection and recovery in case of unexpected events or data loss.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is a MySQL Connection String?
&lt;/h3&gt;

&lt;p&gt;A MySQL connection string is a string that contains the information needed to connect to a MySQL database. It typically includes details like the host, port, username, password, and database name.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is a MySQL Dump?
&lt;/h3&gt;

&lt;p&gt;A MySQL dump is a file that contains a SQL script with all the commands needed to recreate a database. It includes table structures and data.&lt;/p&gt;

&lt;h3&gt;
  
  
  How to Restore a MySQL Backup?
&lt;/h3&gt;

&lt;p&gt;To restore a MySQL backup, you need to have a dump file. You can use tools like SimpleRestore.io to easily upload and restore the backup to your desired database.&lt;/p&gt;

&lt;h3&gt;
  
  
  How to Create a MySQL Backup for PlanetScale?
&lt;/h3&gt;

&lt;p&gt;You can create a MySQL backup for PlanetScale using the &lt;a href="https://github.com/mydumper/mydumper" rel="noopener noreferrer"&gt;MyDumper tool&lt;/a&gt; or by using a backup service like &lt;a href="https://simplebackups.com" rel="noopener noreferrer"&gt;SimpleBackups&lt;/a&gt;. Both methods involve generating a dump file that can be used for restoration.&lt;/p&gt;

</description>
      <category>mysql</category>
      <category>planetscale</category>
      <category>database</category>
      <category>restore</category>
    </item>
    <item>
      <title>The Complete Redis Backup Guide (with examples)</title>
      <dc:creator>Laurent Lemaire</dc:creator>
      <pubDate>Mon, 15 Aug 2022 08:45:05 +0000</pubDate>
      <link>https://dev.to/simplebackups/the-complete-redis-backup-guide-with-examples-108o</link>
      <guid>https://dev.to/simplebackups/the-complete-redis-backup-guide-with-examples-108o</guid>
      <description>&lt;p&gt;In this article, we’ll see how you a real case example of a Redis backup process, end-to-end.&lt;/p&gt;

&lt;p&gt;We'll cover &lt;strong&gt;how to configure a Redis backup&lt;/strong&gt;, which binaries you should use and the most important settings you need to be aware of, as well as how to store your backup remotely and how to restore it.&lt;/p&gt;

&lt;p&gt;Let's get started!&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Redis?
&lt;/h2&gt;

&lt;p&gt;Redis is an open source in-memory key-value store written in C.&lt;br&gt;
Redis stands for Remote Dictionary Server and is used as a database, cache, queue system, and message broker.&lt;/p&gt;

&lt;p&gt;Redis is fast because its data is stored in memory, meaning, unlike traditional databases Redis doesn't need to access the disk.&lt;br&gt;
While writing this article I learned that Redis is often called a "Data Structure Server" because it provides data types that are similar to those in modern programming languages.&lt;/p&gt;

&lt;p&gt;Some data structures that Redis provides are Strings, Lists, Sets, Hashes, and Sorted Sets.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://redis.io/topics/data-types"&gt;Redis Data Types →&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  What is Redis used for?
&lt;/h3&gt;

&lt;p&gt;Even though Redis could be used as your primary Database it's usually not what it is used for.&lt;br&gt;
Here are the most common use cases for Redis:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Cache:&lt;/strong&gt; Redis is used as a cache, which is a fast way to store data in memory.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Session storage:&lt;/strong&gt; Redis is used to store session data. Writing and reading data out of Redis is super fast which makes it an ideal candidate for session storage.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Message queue&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There are a lot of different use cases for Redis, but these are the most common ones.&lt;/p&gt;
&lt;h3&gt;
  
  
  Where is Redis database stored?
&lt;/h3&gt;

&lt;p&gt;As stated above Redis is storing its data in memory. But depending on your use case Redis can copy the data on your disk.&lt;br&gt;
This comes obviously handy when you have a large amount of data, and you need to be able to restore it and this is also why you might be needing to back it up.&lt;/p&gt;

&lt;p&gt;Redis regularly dumps its data to an RDB file on the disk based on how snapshots are configured.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Redis configuration&lt;/strong&gt;&lt;br&gt;
The&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
 file contains your Redis configuration.

The configuration file is located at

 ```/etc/redis/redis.config```

 and straighforward: it's a list of instructions.
You'll find a section called

 ```#### SNAPSHOTTING ####```

 on which you can define if Redis should snapshot its data to the dis and how often it should do it.



```redis.config
save 60 1000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;This configuration will make Redis dump the dataset to the disk every 60 seconds if at least 1000 keys are changed.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://redis.io/docs/manual/config/"&gt;Learn more about Redis Configuration →&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Redis also works with AOF (Append-Only File) which is a way to store the data on the disk by logging all write operations received by the server.&lt;br&gt;
AOS won't be covered in this article but it is worth knowing it exists, especially when you'll need to backup and restore your data.&lt;/p&gt;
&lt;h2&gt;
  
  
  How to back up Redis data
&lt;/h2&gt;

&lt;p&gt;Making a Redis backup is pretty easy. You'll need to make a fresh copy of the RDB file, compress it and save it somewhere safe.&lt;/p&gt;
&lt;h2&gt;
  
  
  Redis offers 2 methods to "force" a snapshot:
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
: This will force a snapshot to be taken synchronously.
-

 ```BGSAVE```

: This will force a snapshot to be taken asynchronously.

The easiest way is to use the

 ```SAVE```

 method but it will block all other operations until the snapshot is done.
Using

 ```BGSAVE```

 will make the server continue to accept commands and will not block other operations but you'll have to figure out when the snapshot is this one is asynchronous.

**So, if you want to make a backup you'll need to do the following:**
1. Review / update your Redis configuration.
2. Create a snapshot for your Redis data (known as a "dump"/"rdb file").
3. Save the RDB file to a remote location

### 1. Review / update your Redis configuration.

You'll need to know where your snapshot file will be generated using the redis-cli command described below.

The default location of your Redis config file is

 ```/etc/redis/redis.config```

.
You can also use this command to find the location of your Redis config file:

 ```redis-cli config get dir```

.

You can find the configuration file here [https://redis.io/topics/config](https://redis.io/topics/config).

### 2. Create a snapshot for your Redis data.

#### &amp;lt;u&amp;gt;Using redis-cli

 ```SAVE```

 command&amp;lt;/u&amp;gt;
This method will work synchronously to make a snapshot of your Redis database.
Just ssh into your server and run the following command:

Log in to the database command line interface:


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;redis-cli&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;


You might have to authenticate to your database:


```shell{promptHost: 127.0.0.1}
auth YOUR_PASSWORD_HERE
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;SAVE
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;The output will be something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;OK
&lt;span class="o"&gt;(&lt;/span&gt;1.23s&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can then exit the redis-cli by typing&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
.

At this stage, the

 ```RDB```

 file will be saved in

 ```/var/lib/redis/```

 and will be named

 ```dump.rdb```

.

#### &amp;lt;u&amp;gt;Using redis-cli

 ```BGSAVE```

 command&amp;lt;/u&amp;gt;

Using the asynchronous dump function, you'll need to make sure you are aware of the end of the process.
One way to do it is to use

 ```inotifywait```

 which will notify you when a change to the dump file is made.

### 3. Automate your Redis backups and store them on AWS S3

As stated in [Redis documentation](https://redis.io/docs/manual/persistence/), it's safe to copy the RDB file even if used by your running server:

&amp;gt; Redis is very data backup friendly since you can copy RDB files while the database is running: the RDB is never modified once produced, and while it gets produced it uses a temporary name and is renamed into its final destination atomically using rename(2) only when the new snapshot is complete.
&amp;gt;
&amp;gt; This means that copying the RDB file is completely safe while the server is running. This is what we suggest:
&amp;gt;
&amp;gt; - Create a cron job in your server creating hourly snapshots of the RDB file in one directory, and daily snapshots in a different directory.
&amp;gt; - Every time the cron script runs, make sure to call the find command to make sure too old snapshots are deleted: for instance you can take hourly snapshots for the latest 48 hours, and daily snapshots for one or two months. Make sure to name the snapshots with date and time information.
&amp;gt; - At least one time every day make sure to transfer an RDB snapshot outside your data center or at least outside the physical machine running your Redis instance.


We'll create a script that will create our dump file, then upload to Amazon S3.

#### &amp;lt;u&amp;gt;Create a shell script that will dump the Redis database&amp;lt;/u&amp;gt;


```shell
cd ~
mkdir scripts
cd scripts
nano redis_backup.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Copy and paste the script below to it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#!/bin/bash
rdb_file="/FOLDER_TO_YOUR_REDIS_DUMP_FILE/redis/dump.rdb"
redis_cli="/usr/bin/redis-cli"

DIR=`date +%d-%m-%y`
DEST=~/redis_backups/$DIR
mkdir $DEST

echo save| $redis_cli
exit 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  &lt;u&gt;Send the Redis DUMP to an AWS S3 bucket&lt;/u&gt;
&lt;/h4&gt;

&lt;p&gt;Append to&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
 the following:



```shell
BUCKET_NAME="YOUR_S3_BUCKET_NAME"
aws s3 cp $rdb_file s3://YOUR_S3_BUCKET/redis_backups/ &amp;amp;&amp;amp; echo "Backup copied to S3"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  &lt;u&gt;Schedule the script to run every day at midnight&lt;/u&gt;
&lt;/h4&gt;

&lt;p&gt;First, let's CHMOD the script to make it executable:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;chmod&lt;/span&gt; +x ~/scripts/db_sync.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then create a cron job to run the script every day at midnight:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;crontab &lt;span class="nt"&gt;-e&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;0 0 &lt;span class="k"&gt;*&lt;/span&gt; &lt;span class="k"&gt;*&lt;/span&gt; &lt;span class="k"&gt;*&lt;/span&gt; ~/scripts/redis_backup.sh &lt;span class="c"&gt;# take a backup every midnight&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  How to restore a Redis backup
&lt;/h2&gt;

&lt;p&gt;Now that you've made a backup, we'll see how to restore it from a&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
 file.

**We recommend you first try this on a fresh Redis server**

### Make sure AOF is disabled
AOF stands for Append-Only File, which will instruct Redis to log all operations in a `.aof` file.
Since we're restoring a backup, we need to disable AOF before restoring the data as we don't want Redis to log all these operations.

Open your configuration file (

```redis.config```

) and make sure

 ```appendonly```

 is set to

 ```no```

.



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;appendonly no&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;


### Stopping the Redis server

Before being able to replace the

 ```dump.rdb```

 file, you'll need to stop the Redis server.



```shell
sudo service redis-server stop
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Restoring the Redis database
&lt;/h3&gt;

&lt;p&gt;Prior to restoring the database, you can rename the existing dump.rdb file in order to have a restore point in case something goes wrong.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo cp&lt;/span&gt; /home/redis/dump.rdb /home/redis/dump.rdb.bak
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can then copy the backup rdb file as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo cp&lt;/span&gt; /redis_backups/20220810/dump.rdb /home/redis/dump.rdb
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And finally make sure to apply the right permissions to the dump.rdb file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo chmod &lt;/span&gt;660 /home/redis/dump.rdb
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Re-starting Redis server
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;service redis-server start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Additional Resources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Official Redis documentation: &lt;a href="https://redis.io/docs/manual/persistence/"&gt;https://redis.io/docs/manual/persistence/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Service to automate your Redis backups: &lt;a href="https://simplebackups.com/redis-backup/"&gt;https://simplebackups.com/redis-backup/&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;We've seen how to back up your Redis database and restore it, and we've seen how to automate the process.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;a href="https://simplebackups.com"&gt;SimpleBackups&lt;/a&gt; will save you a lot of time setting up scripts, ensuring they run without problems, all without code or maintenance.&lt;br&gt;
It will alert you when things go wrong, and allows you to store your backups on many cloud storage services like Google, DigitalOcean, Wasabi, Dropbox, and more…&lt;/em&gt;&lt;/p&gt;

</description>
      <category>redis</category>
      <category>backup</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Cloud Storage Comparison - Best Providers 2021</title>
      <dc:creator>Laurent Lemaire</dc:creator>
      <pubDate>Thu, 07 Oct 2021 13:59:58 +0000</pubDate>
      <link>https://dev.to/simplebackups/cloud-storage-comparison-best-providers-2021-2cnf</link>
      <guid>https://dev.to/simplebackups/cloud-storage-comparison-best-providers-2021-2cnf</guid>
      <description>&lt;p&gt;We've created a list of all major (and our preferred) providers, together with their prices using the region &lt;strong&gt;US-EAST-1&lt;/strong&gt; as reference.&lt;/p&gt;

&lt;p&gt;If you're looking to store your data on a Cloud Storage Provider, you've got plenty of choices.&lt;/p&gt;

&lt;p&gt;Prices are often changing and what each provider offer is different.&lt;br&gt;
Once you know your needs in terms of storage/frequency of access (...), you'll easily be able to identify which provider fits you the best.&lt;/p&gt;

&lt;p&gt;This list doesn't contain all the specificities each provider offers as we tried to summarize what most people are looking for when it comes to evaluating an Object Block Storage provider.&lt;/p&gt;

&lt;p&gt;If you want to see any additional information in this comparison &lt;a href="//mailto:contact@simplebackups.io"&gt;just let us know&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Object Storage Providers Comparison
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Name&lt;/th&gt;
&lt;th&gt;Price /GB/month&lt;/th&gt;
&lt;th&gt;Min price/month&lt;/th&gt;
&lt;th&gt;Price/1000 requests&lt;/th&gt;
&lt;th&gt;Price Ingress&lt;/th&gt;
&lt;th&gt;Price Egress&lt;/th&gt;
&lt;th&gt;Link&lt;/th&gt;
&lt;th&gt;Extra&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;AWS S3&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;$0.02&lt;/td&gt;
&lt;td&gt;-&lt;/td&gt;
&lt;td&gt;$0.01&lt;/td&gt;
&lt;td&gt;$0.00&lt;/td&gt;
&lt;td&gt;$0.09/GB/month (1GB/m included)&lt;/td&gt;
&lt;td&gt;&lt;a href="https://aws.amazon.com/s3/pricing/"&gt;https://aws.amazon.com/s3/pricing/&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;- 12 first months free   - 5GB free&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;AWS S3 - Infrequent access&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;$0.01&lt;/td&gt;
&lt;td&gt;-&lt;/td&gt;
&lt;td&gt;$0.01&lt;/td&gt;
&lt;td&gt;$0.00&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href="https://aws.amazon.com/s3/pricing/"&gt;https://aws.amazon.com/s3/pricing/&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;AWS Glacier&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;$0.00&lt;/td&gt;
&lt;td&gt;-&lt;/td&gt;
&lt;td&gt;$0.03&lt;/td&gt;
&lt;td&gt;$0.00&lt;/td&gt;
&lt;td&gt;$0.01/GB&lt;/td&gt;
&lt;td&gt;
&lt;a href="https://aws.amazon.com/s3/pricing/"&gt;https://aws.amazon.com/s3/pricing/&lt;/a&gt;   &lt;a href="https://aws.amazon.com/s3/pricing/"&gt;https://aws.amazon.com/s3/pricing/&lt;/a&gt;
&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Wasabi&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;$0.01&lt;/td&gt;
&lt;td&gt;-&lt;/td&gt;
&lt;td&gt;$0.00&lt;/td&gt;
&lt;td&gt;$0.00&lt;/td&gt;
&lt;td&gt;$0.00&lt;/td&gt;
&lt;td&gt;&lt;a href="https://wasabi.com/cloud-storage-pricing/#cost-estimates"&gt;https://wasabi.com/cloud-storage-pricing/#cost-estimates&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Blackblaze&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;$0.01&lt;/td&gt;
&lt;td&gt;-&lt;/td&gt;
&lt;td&gt;$0.00&lt;/td&gt;
&lt;td&gt;$0.00&lt;/td&gt;
&lt;td&gt;$0.01/GB&lt;/td&gt;
&lt;td&gt;&lt;a href="https://www.backblaze.com/b2/cloud-storage-pricing.html"&gt;https://www.backblaze.com/b2/cloud-storage-pricing.html&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;DigitalOcean Spaces&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;$0.02&lt;/td&gt;
&lt;td&gt;$5 (250GB included)&lt;/td&gt;
&lt;td&gt;$0.00&lt;/td&gt;
&lt;td&gt;$0.00&lt;/td&gt;
&lt;td&gt;$0.00&lt;/td&gt;
&lt;td&gt;&lt;a href="https://www.digitalocean.com/pricing/"&gt;https://www.digitalocean.com/pricing/&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;- Minimum 5$   - 1 TB of outbound transfer (additional 0.01/GB)   - Additional storage 0.02/GB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Dropbox&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;$0.00&lt;/td&gt;
&lt;td&gt;$12 (5TB included)&lt;/td&gt;
&lt;td&gt;$0.00&lt;/td&gt;
&lt;td&gt;$0.00&lt;/td&gt;
&lt;td&gt;$0.00&lt;/td&gt;
&lt;td&gt;&lt;a href="https://www.dropbox.com/plans?tab=work#features"&gt;https://www.dropbox.com/plans?tab=work#features&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;- Reference: Plan standard   - Minimum 12$/m&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Google Cloud Storage&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;$0.02&lt;/td&gt;
&lt;td&gt;-&lt;/td&gt;
&lt;td&gt;$0.01&lt;/td&gt;
&lt;td&gt;$0.00&lt;/td&gt;
&lt;td&gt;$0.12&lt;/td&gt;
&lt;td&gt;&lt;a href="https://cloud.google.com/storage/pricing"&gt;https://cloud.google.com/storage/pricing&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;- Reference: Standard   - 5GB free + 5000 operations&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;FileBase&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;$0.01&lt;/td&gt;
&lt;td&gt;-&lt;/td&gt;
&lt;td&gt;$0.00&lt;/td&gt;
&lt;td&gt;$0.00&lt;/td&gt;
&lt;td&gt;0.0059/GB (1TB included)&lt;/td&gt;
&lt;td&gt;&lt;a href="https://filebase.com/"&gt;https://filebase.com/&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;- Minimum 5.99/m&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Azure Blob Storage&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;$0.02&lt;/td&gt;
&lt;td&gt;-&lt;/td&gt;
&lt;td&gt;$0.0065-$0.0005&lt;/td&gt;
&lt;td&gt;$0.00&lt;/td&gt;
&lt;td&gt;n/a&lt;/td&gt;
&lt;td&gt;&lt;a href="https://azure.microsoft.com/en-us/pricing/details/storage/blobs/#overview"&gt;https://azure.microsoft.com/en-us/pricing/details/storage/blobs/#overview&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;- Reference: Hot Storage&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Exoscale&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;$0.02&lt;/td&gt;
&lt;td&gt;-&lt;/td&gt;
&lt;td&gt;$0.00&lt;/td&gt;
&lt;td&gt;$0.00&lt;/td&gt;
&lt;td&gt;$0.02&lt;/td&gt;
&lt;td&gt;&lt;a href="https://www.exoscale.com/pricing/#storage"&gt;https://www.exoscale.com/pricing/#storage&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;UpCloud&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;$0.02&lt;/td&gt;
&lt;td&gt;-&lt;/td&gt;
&lt;td&gt;$0.00&lt;/td&gt;
&lt;td&gt;$0.00&lt;/td&gt;
&lt;td&gt;$0.01&lt;/td&gt;
&lt;td&gt;&lt;a href="https://upcloud.com/pricing/#object-storage"&gt;https://upcloud.com/pricing/#object-storage&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;- Reference 250GB plan&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Vultr&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;$0.02&lt;/td&gt;
&lt;td&gt;-&lt;/td&gt;
&lt;td&gt;$0.00&lt;/td&gt;
&lt;td&gt;$0.00&lt;/td&gt;
&lt;td&gt;$0.01/GB (1TB included)&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;- Minimu: 5$ (250gb)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;em&gt;This list is maintained and updated monthly - **last update: 20/09/2021)&lt;/em&gt;* *&lt;/p&gt;

</description>
      <category>backup</category>
      <category>cloudprovider</category>
      <category>s3</category>
      <category>objectstorage</category>
    </item>
    <item>
      <title>Restore MongoDB Atlas Collection using MongoDB Compass</title>
      <dc:creator>zOxta</dc:creator>
      <pubDate>Wed, 06 Oct 2021 12:40:44 +0000</pubDate>
      <link>https://dev.to/simplebackups/restore-mongodb-atlas-collection-using-mongodb-compass-4mn7</link>
      <guid>https://dev.to/simplebackups/restore-mongodb-atlas-collection-using-mongodb-compass-4mn7</guid>
      <description>&lt;p&gt;So you already have your backup and decided to restore this on your MongoDB Atlas database? In this tutorial, we will tackle restoring a MongoDB Collection into MongoDB Atlas using MongoDB Compass.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;MongoDB Atlas Cluster&lt;/li&gt;
&lt;li&gt;MongoDB Compass Installed &lt;/li&gt;
&lt;li&gt;A MongoDB database collection backup; if you don't have one, SimpleBackups can help you &lt;a href="https://simplebackups.com/mongodb-backup/" rel="noopener noreferrer"&gt;backing up your MongoDB Atlas&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;MongoDB Atlas&lt;/strong&gt; is a fully-managed cloud database developed by the same people that build MongoDB.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;MongoDB Compass&lt;/strong&gt; is a GUI that allows you to analyze your documents and displays rich structures within your collections.&lt;/p&gt;

&lt;p&gt;In this article we will go through connecting to our MongoDB Atlas database using MongoDB Compass and importing a sample collection into your MongoDB Atlas database.&lt;/p&gt;




&lt;h2&gt;
  
  
  Grab your MongoDB Atlas Database Credentials
&lt;/h2&gt;

&lt;p&gt;Head over to &lt;a href="https://cloud.mongodb.com/v2/" rel="noopener noreferrer"&gt;https://cloud.mongodb.com/v2/&lt;/a&gt; then choose your MongoDB cluster and click on "Connect" on the cluster you want to connect to.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://downloads.intercomcdn.com/i/o/399577689/01912fa8a9361f3f373a6f58/SimpleBackups-Mongo-NewConnection1.png" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdownloads.intercomcdn.com%2Fi%2Fo%2F399577689%2F01912fa8a9361f3f373a6f58%2FSimpleBackups-Mongo-NewConnection1.png" alt="SimpleBackups - MongoDB Atlas Connect to Cluster"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When the list of option pops up, make sure you choose the MongoDB Compass option.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://downloads.intercomcdn.com/i/o/399579719/e016bf02d42f282d9c9b8bde/SimpleBackups-Mongo-NewConnection5.png" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdownloads.intercomcdn.com%2Fi%2Fo%2F399579719%2Fe016bf02d42f282d9c9b8bde%2FSimpleBackups-Mongo-NewConnection5.png" alt="SimpleBackups - MongoDB Atlas Connect to Cluster via Compass"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From this screen, you can copy the connection string at the bottom which includes the connection details (username, password placeholder, database host and so on).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; this is the connection string you can add to SimpleBackups when backing up your MongoDB Atlas database.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://downloads.intercomcdn.com/i/o/399580536/abb31ea82d837e8c1e9fb60a/SimpleBackups-Mongo-NewConnection6.png" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdownloads.intercomcdn.com%2Fi%2Fo%2F399580536%2Fabb31ea82d837e8c1e9fb60a%2FSimpleBackups-Mongo-NewConnection6.png" alt="SimpleBackups - MongoDB Atlas Grab Connection String"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Connect to MongoDB Atlas via MongoDB Compass
&lt;/h2&gt;

&lt;p&gt;Paste the connection string you obtained from the previous step.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; make sure you replace &lt;code&gt;&amp;lt;password&amp;gt;&lt;/code&gt; from the connection string by the actual password of your MongoDB Atlas user.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://downloads.intercomcdn.com/i/o/399581169/96937fff4f94951ae6ff1ae6/SimpleBackups-Mongo-NewConnection.png" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdownloads.intercomcdn.com%2Fi%2Fo%2F399581169%2F96937fff4f94951ae6ff1ae6%2FSimpleBackups-Mongo-NewConnection.png" alt="SimpleBackups - MongoDB Compass Connect Atlas"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Import MongoDB Atlas collection via MongoDB Compass
&lt;/h2&gt;

&lt;p&gt;When you connect successfully, you will see all databases under your MongoDB on the left as shown above. Select the database and the collection you want to import the data into. In this case, we had a MongoDB database called &lt;code&gt;myDatabase&lt;/code&gt; and a collection called &lt;code&gt;myCollection&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;When you select the target collection form the left hand side, click "ADD DATA" and then "Import File".&lt;/p&gt;

&lt;p&gt;&lt;a href="https://downloads.intercomcdn.com/i/o/399586765/a4883f5271b33704e7fa5abd/SimpleBackups-MongoDB-Atlas-Import-Compass-NewConnection1.png" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdownloads.intercomcdn.com%2Fi%2Fo%2F399586765%2Fa4883f5271b33704e7fa5abd%2FSimpleBackups-MongoDB-Atlas-Import-Compass-NewConnection1.png" alt="SimpleBackups-MongoDB-Atlas-Import-Compass-NewConnection1"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Finally, on the screen below, you can select the JSON document (MongoDB collection) you want to import.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://downloads.intercomcdn.com/i/o/399586810/6cdb1d200047e5b1a86b7171/SimpleBackups-MongoDB-Atlas-Import-Compass-NewConnection2.png" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdownloads.intercomcdn.com%2Fi%2Fo%2F399586810%2F6cdb1d200047e5b1a86b7171%2FSimpleBackups-MongoDB-Atlas-Import-Compass-NewConnection2.png" alt="SimpleBackups-MongoDB-Atlas-Import-Compass-NewConnection2"&gt;&lt;/a&gt;&lt;/p&gt;




</description>
      <category>mongodb</category>
      <category>database</category>
      <category>cloud</category>
    </item>
    <item>
      <title>The Complete mysqldump Guide (with examples)</title>
      <dc:creator>zOxta</dc:creator>
      <pubDate>Tue, 08 Dec 2020 22:55:52 +0000</pubDate>
      <link>https://dev.to/simplebackups/the-complete-mysqldump-guide-with-examples-3lja</link>
      <guid>https://dev.to/simplebackups/the-complete-mysqldump-guide-with-examples-3lja</guid>
      <description>&lt;p&gt;Databases are essential tools to collect and store mountains of data. All complex applications use them to store information.&lt;br&gt;
There are many database solutions out there, but MySQL is one of the most popular. Using MySQL is vital to keeping these databases secure and running smoothly. &lt;/p&gt;

&lt;p&gt;Managing and backing up servers and databases can all be done in MySQL.&lt;br&gt;
To help these complex processes run smoothly, utilities have been developed. Mysqldump is one of those tools meant to make the lives of developers easier. &lt;/p&gt;

&lt;p&gt;In this guide, we are going to walk you through what utility is, how to use it, identify some common errors, and provide some clear examples along the way so that you will be able to use mysqldump effectively.&lt;/p&gt;
&lt;h2&gt;
  
  
  What is mysqldump?
&lt;/h2&gt;

&lt;p&gt;MySQL is a database system that has been around for years and continues to be one of the most popular choices for websites. It's open-source and agile. Developers can use these databases to store anything a website may need. The information stored in online databases can range from consumer info and simple text to picture galleries to network information.&lt;/p&gt;

&lt;p&gt;Mysqldump is part of the relational database package for MySQL. It is used to back up all the data in a database into a single text file. These files or "dumps" can be generated for individual databases or a collection of them. The text in the file is displayed as a set of SQL statements that can later be reconstructed into its original state.&lt;/p&gt;

&lt;p&gt;The purpose of this tool is to export a database to a backup file or to move the database to another web host. Other delimited text formats like XML and CSV can also be generated with mysqldump. These simple queries make the backup process easier.&lt;/p&gt;
&lt;h2&gt;
  
  
  The importance of backing up data
&lt;/h2&gt;

&lt;p&gt;Companies that hope to run smoothly need pristine copies of their data at different points in time. Without a backup strategy, there is nothing to protect them in the case of a disaster. The ease in which the data can be lost forever is too much to cope with as data can easily become corrupted or get lost over time. Malicious intent and natural disasters are not a requirement for worst-case scenarios to transpire.&lt;/p&gt;

&lt;p&gt;Having backups at periodic intervals gives the company the ability to rewind the clock by reloading the previous database. If something breaks or fails, this acts as a lifeline for the system. The company also has data versioning available. Different versions of the database and product are available to go back to. Critical changes that later prove to break the system can be undone, then you can restore the old versions without the problem.&lt;/p&gt;

&lt;p&gt;By backing up everything, migrations to new servers or development environments transpire without the fear that data will be lost.&lt;/p&gt;
&lt;h2&gt;
  
  
  How to use mysqldump
&lt;/h2&gt;

&lt;p&gt;By using mysqldump, a developer can get a hold of the .sql file that serves as a back up for the entire database. To use the tool, the developer needs access to the server running the instance of MySQL. The required privileges have to be given to export anything. The user credentials for the database will also be needed, including the username and password.&lt;/p&gt;

&lt;p&gt;The three ways that mysqldump is used to export data includes:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Exporting specific tables in a MySQL database&lt;/li&gt;
&lt;li&gt;Exporting single databases&lt;/li&gt;
&lt;li&gt;Exporting the entire MySQL server&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;
  
  
  Exporting MySQL tables
&lt;/h3&gt;

&lt;p&gt;Make sure you are on a machine that has MySQL installed. You will also need a valid database user with -at minimum- full read access privileges. This should do for basic options, but more advanced commands may require additional privileges. With that in order, launch a terminal where you will send the command to back up the tables.&lt;/p&gt;

&lt;p&gt;Match your inputs to conform to the following command structure:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mysqldump [options] db_name [table_name ...]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For the live command, replace &lt;code&gt;[options]&lt;/code&gt; with the valid option names or flags. These will most likely include &lt;code&gt;-u&lt;/code&gt; and &lt;code&gt;-p&lt;/code&gt;, which stands for user and password. When using more than one option, be careful of the order they are listed in because they will be processed in order from first to last. Here, &lt;code&gt;[table_name…]&lt;/code&gt; will be replaced by the name of the table you are exporting. Different tables must be separated by spaces. The following example is for backing up tables called &lt;code&gt;mystery&lt;/code&gt; and &lt;code&gt;cash&lt;/code&gt;, and the name of the database is &lt;code&gt;db_cooper&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mysqldump &lt;span class="nt"&gt;-u&lt;/span&gt; username &lt;span class="nt"&gt;-p&lt;/span&gt; db_cooper mystery cash &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; file_name.sql
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You will then provide the password for the database user because it is not passed along with the &lt;code&gt;-p&lt;/code&gt; flag. The &lt;code&gt;&amp;gt;&lt;/code&gt; character indicates the output redirection that will create the dump file. Here, &lt;code&gt;file_name&lt;/code&gt; is what the final file will be called.&lt;/p&gt;

&lt;h3&gt;
  
  
  Exporting a MySQL database
&lt;/h3&gt;

&lt;p&gt;The steps for exporting a database are very close to those for exporting a table. There is just a small change in the format of the command. You will need the same server access and credentials.&lt;/p&gt;

&lt;p&gt;Match your inputs to conform to the following command structure:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mysqldump &lt;span class="nt"&gt;-u&lt;/span&gt; username &lt;span class="nt"&gt;-p&lt;/span&gt; &lt;span class="nt"&gt;--databases&lt;/span&gt; db_larry db_curly db_moe &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; file_name.sql
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The database you will export comes after the &lt;code&gt;--databases&lt;/code&gt; option. The space character separates multiple databases.&lt;/p&gt;

&lt;h3&gt;
  
  
  Exporting a MySQL server
&lt;/h3&gt;

&lt;p&gt;The command is very similar for entire servers as well.&lt;/p&gt;

&lt;p&gt;Match your inputs to conform to the following command structure:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mysqldump &lt;span class="nt"&gt;-u&lt;/span&gt; username &lt;span class="nt"&gt;-p&lt;/span&gt; &lt;span class="nt"&gt;--all-databases&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The command itself is pretty basic, with &lt;code&gt;--all-databases&lt;/code&gt; indicating that everything on the server should be dumped. If there are specific requirements, that is where the options come in for the command. Adding -compatible will make the file that gets exported compatible with older MySQL servers or database systems.&lt;/p&gt;

&lt;p&gt;Developers using PowerShell on Windows will need to include -result-file as an option. This will specify the file name and make sure that the output is in ASCII format so that it will load correctly later.&lt;/p&gt;

&lt;p&gt;Other common options include adding &lt;code&gt;--no-data&lt;/code&gt; will only back up the database structure, using --no-create-info backs up the database without any structure.&lt;/p&gt;

&lt;h2&gt;
  
  
  Importing a mysqldump
&lt;/h2&gt;

&lt;p&gt;Importing a .sql file is straight forward. The only kink is to make sure the target server has a blank database before importing anything.&lt;/p&gt;

&lt;p&gt;Match your inputs to conform to the following command structure:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mysql &lt;span class="nt"&gt;-u&lt;/span&gt; root &lt;span class="nt"&gt;-pmypassword&lt;/span&gt; wpdb &amp;lt; db_backup.sql
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The mysqlimport command will also work on databases you want to restore that already exists on the target machine:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mysqlimport &lt;span class="nt"&gt;-u&lt;/span&gt; root &lt;span class="nt"&gt;-pmypassword&lt;/span&gt; wpdb &amp;lt; wpdb_backup.sql
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You also have the option to import all databases by running a command that looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mysql &lt;span class="nt"&gt;-u&lt;/span&gt; root &lt;span class="nt"&gt;-pmypassword&lt;/span&gt; &amp;lt; alldb_backup.sql
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  What does the --quick flag do?
&lt;/h2&gt;

&lt;p&gt;Mysqldump can operate in one of two ways. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The tool can go grab all data at once, buffer it in memory, and then dump it. &lt;/li&gt;
&lt;li&gt;It dumps the tables row by row.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The second method is important when dealing with large tables. By using the &lt;code&gt;--quick&lt;/code&gt; flag, mysqldump reads large databases without needing large amounts of RAM to fit the full table into the memory. &lt;br&gt;
This ensures that the databases will be read and copied correctly on systems with small amounts of RAM and large data sets.&lt;/p&gt;
&lt;h2&gt;
  
  
  Does the "where" clause work with mysqldump?
&lt;/h2&gt;

&lt;p&gt;Yes, this clause works with the command line. This makes it easy to set conditions on the data you need to dump from the database. If there is a large enterprise that has been in business for decades that wants to pull the information after April 27, 2017, then this clause allows that to happen. The where clause passes a string for the condition and grabs the specific records requested.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mysqldump &lt;span class="nt"&gt;-u&lt;/span&gt; root &lt;span class="nt"&gt;-pmypassword&lt;/span&gt; wpdb &lt;span class="nt"&gt;--tables&lt;/span&gt; thetable &lt;span class="nt"&gt;--where&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"date_created &amp;gt; '2017-04-27'"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; wpdb_myrecord.sql
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Troubleshooting common errors
&lt;/h2&gt;

&lt;p&gt;Along the way you may face some MySQL common errors that are -to some degree- easy to mitigate. We will share below some of these errors and how to solve them.&lt;/p&gt;

&lt;h4&gt;
  
  
  Error 2013: lost connection to mysql server during query when dumping table
&lt;/h4&gt;

&lt;p&gt;To fix this issue, you need to go into the MySQL configuration file and increase some values. When those are added, save and close the file, then restart MySQL for the changes to take effect.&lt;/p&gt;

&lt;p&gt;The values you need to adjust are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;max_allowed_packet&lt;/li&gt;
&lt;li&gt;net_write_timeout&lt;/li&gt;
&lt;li&gt;net_read_timeout&lt;/li&gt;
&lt;li&gt;innodb_buffer_pool_size&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The adjustments to the file will be under the &lt;code&gt;[mysqld]&lt;/code&gt; and &lt;code&gt;[mysqldump]&lt;/code&gt; sections and will look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[mysqld]
innodb_buffer_pool_size=100M
max_allowed_packet=1024M
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[mysqldump]
max_allowed_packet=1024M
net_read_timeout=3600
net_write_timeout=3600
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Error 2020: got packet bigger than 'max_allowed_packet' bytes when dumping table
&lt;/h4&gt;

&lt;p&gt;If the database you need to back up is large, and the file size ends up bigger thant the maximum allowed packet size, this error pops up.&lt;/p&gt;

&lt;p&gt;This error can be fixed by going into the MySQL configuration file and increasing max_allowed_packet value in the &lt;code&gt;[mysqld]&lt;/code&gt; and &lt;code&gt;[mysqldump]&lt;/code&gt; sections. Save and close the file when finished, then restart MySQL for the changes to take effect.&lt;/p&gt;

&lt;p&gt;The changes will look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[mysqld]
max_allowed_packet=desired-value
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[mysqldump]
max_allowed_packet=desired-value
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Table does not exist (1146), couldn't execute 'show create table x'
&lt;/h4&gt;

&lt;p&gt;There may be times when you delete a table during backing up. If this is the case, you can restrict certain tables from the mysqldump command with the &lt;code&gt;--ignore-table&lt;/code&gt; option. To identify the table, you will have to state both the database and table names.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mysqldump &lt;span class="nt"&gt;-u&lt;/span&gt; root &lt;span class="nt"&gt;-pmypassword&lt;/span&gt; example_db &lt;span class="nt"&gt;--ignore-table&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;name_of_table &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; db_backup.sql
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By listing the option multiple times, you can ignore multiple tables:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mysqldump &lt;span class="nt"&gt;-u&lt;/span&gt; root &lt;span class="nt"&gt;-pmypassword&lt;/span&gt; example_db &lt;span class="nt"&gt;--ignore-table&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;table &lt;span class="nt"&gt;--ignore-table&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;tableaux &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; db_backup.sql
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Selecting the database returns 'unknown database'
&lt;/h4&gt;

&lt;p&gt;This error happens most often when you use the &lt;code&gt;-p&lt;/code&gt; flag in the command line with the password and there is a space in between &lt;code&gt;-p&lt;/code&gt; and &lt;code&gt;mypassword&lt;/code&gt;. If this happens when using "root" as the user with a password of "base-face", there will be an error stating "Unknown database base-face."&lt;/p&gt;

&lt;p&gt;The correct input would look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mysqldump &lt;span class="nt"&gt;-u&lt;/span&gt; root &lt;span class="nt"&gt;-pbase-face&lt;/span&gt; wpdb &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; wpdb_backup.sql
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Error 1044 when selecting the database
&lt;/h4&gt;

&lt;p&gt;If the user trying to do the dump doesn't have the privileges necessary to access the database, this error occurs. Logging into MySQL and assigning those privileges to the user will fix the issue. Enter command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mysql &lt;span class="nt"&gt;-u&lt;/span&gt; root &lt;span class="nt"&gt;-p&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then enter the correct password, and proceed to grant privileges to the selected user.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;GRANT&lt;/span&gt; &lt;span class="k"&gt;ALL&lt;/span&gt; &lt;span class="k"&gt;PRIVILEGES&lt;/span&gt; &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;wpdb&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;TO&lt;/span&gt; &lt;span class="s1"&gt;'not_a_hacker'&lt;/span&gt;&lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="s1"&gt;'inconspicuous_host'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After that, flush the privileges and exit from MySQL by entering the command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="n"&gt;FLUSH&lt;/span&gt; &lt;span class="k"&gt;PRIVILEGES&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="n"&gt;EXIT&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Access denied for user when trying to connect to mysqldump
&lt;/h4&gt;

&lt;p&gt;This error has several possible causes. Here's three of the most common causes of the issue.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Wrong mysqldump command&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If you are using the wrong command, then this error will appear. The command may be mostly correct but it's missing a critical ingredient in the mysqldump format. The basic command will look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mysqldump &lt;span class="nt"&gt;-u&lt;/span&gt; user &lt;span class="nt"&gt;-pmypasword&lt;/span&gt; database &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; database.sql
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you fail to specify a username or password then it will spit back the following message:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mysqldump: Got error: 1045: &lt;span class="s2"&gt;"Access denied for user 'user' @ 'localhost' (using password: NO)"&lt;/span&gt; when trying to connect
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Remote host not allowed to connect to database&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This error comes up if the backup is trying to be done on a remote server. The configurations for MySQL are set to disallow external connections. Here, the localhost is the only one allowed to make a backup. This is a security measure, so it's a good measure to have but if you need to change this, go to configurations and change MySQL to allow connections from a remote host.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Wrong user credentials&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If you try to use the wrong username and password combination while connecting to the database, this error happens. MySQL can't verify that the request is authentic and returns the error. You'll have to make the request again with proper credentials, make sure there aren't any typos in your original command as that is the easiest mistake to make.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Mysqldump is a useful tool to help back up databases with minimal commands. One command allows the entire database to be spit out into a single text file. The tool is versatile enough to back up the parts of the database that is needed and comes with a variety of options to change the data you need to save.&lt;/p&gt;




&lt;blockquote&gt;
&lt;p&gt;Automated MySQL Backups using SimpleBackups&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://simplebackups.com"&gt;SimpleBackups.com&lt;/a&gt; is a database and website backup automation tool. It automates &lt;a href="https://simplebackups.com/mysql-backup/"&gt;MySQL backups&lt;/a&gt; using mysqldump to securely dump your MySQL databases and send them offsite to the cloud for storage. When you need to ensure your MySQL backups are secure, you can trust SimpleBackups to take care of it for you.&lt;/p&gt;

</description>
      <category>mysql</category>
      <category>database</category>
      <category>webdev</category>
      <category>bash</category>
    </item>
    <item>
      <title>The Ultimate MySQL Database Backup Script</title>
      <dc:creator>Laurent Lemaire</dc:creator>
      <pubDate>Sat, 13 Jun 2020 09:43:12 +0000</pubDate>
      <link>https://dev.to/simplebackups/the-ultimate-mysql-database-backup-script-12g2</link>
      <guid>https://dev.to/simplebackups/the-ultimate-mysql-database-backup-script-12g2</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Any database, needs a backup&lt;/strong&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This article is part of “The Ultimate Backup Script” series we are creating to provide you with database backup scripts that not only allow you to create database backups, but also upload the backup dumps to Amazon S3 and automate the process daily.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--W2Feirq5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://simplebackups.io/images/uploads/simplebackups-mysql-backup-storage.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--W2Feirq5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://simplebackups.io/images/uploads/simplebackups-mysql-backup-storage.png" alt="MySQL Backup Illustration" title="MySQL Backup Illustration" width="800" height="536"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Why we need a database backup?
&lt;/h3&gt;

&lt;p&gt;One might think why backup is necessary for my database? The answer is simple, backup creates a copy of your physical, logical, and operational data. Which you can store at any safe place such as Amazon S3. This copy comes into use if the running database gets corrupted. Database backup can include files like control files, datafiles, and archived redo logs.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why Amazon S3 for backup?
&lt;/h3&gt;

&lt;p&gt;For this tutorial, we have chosen Amazon S3 as it is a very common choice. You can do the same thing if you would like to use another clould storage provider. The instructions won’t differ a lot as long as the cloud provider is S3-compatible.&lt;/p&gt;

&lt;p&gt;Below we defined some less known terms that we used in the article:&lt;/p&gt;

&lt;h3&gt;
  
  
  What is Cron?
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;Cron is a software utility that offers time-based job scheduling. It supports Unix computer operating systems. To set up software environments, the developer uses Cron. He/she schedules commands or shell scripts so that they run at chosen times. It could be daily, once a week, or any interval as desired.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  What is Chmod?
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;The chmod a short command of ‘change mode’ enables the admin to set rules for file handling. In other words, with the help of a “chmod” system call. An administrator can change the access permissions of file system objects.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4&gt;
  
  
  Database Backup Script for MySQL and Dumping to Amazon S3
&lt;/h4&gt;

&lt;p&gt;You can automate the creation of backup and storing it to Amazon S3 within a few minutes. Below bullets brief about what you are going to learn in this part of the article:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create a script that automates the MySQL backup directory creation&lt;/li&gt;
&lt;li&gt;Upload/sync the backups with Amazon S3&lt;/li&gt;
&lt;li&gt;Cron will run this command every day (to back up)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step 1: Generating a shell script which will dump the MySQL database
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; ~
&lt;span class="nb"&gt;mkdir &lt;/span&gt;scripts
&lt;span class="nb"&gt;cd &lt;/span&gt;scripts
nano db_backup.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Copy and paste the script below to it&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;
&lt;span class="nv"&gt;DIR&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sb"&gt;`&lt;/span&gt;&lt;span class="nb"&gt;date&lt;/span&gt; +%d-%m-%y&lt;span class="sb"&gt;`&lt;/span&gt;
&lt;span class="nv"&gt;DEST&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;~/db_backups/&lt;span class="nv"&gt;$DIR&lt;/span&gt;
&lt;span class="nb"&gt;mkdir&lt;/span&gt; &lt;span class="nv"&gt;$DEST&lt;/span&gt;

mysqldump &lt;span class="nt"&gt;-h&lt;/span&gt; mysql_hostname &lt;span class="nt"&gt;-u&lt;/span&gt; mysql_user  &lt;span class="nt"&gt;-p&lt;/span&gt;&lt;span class="s2"&gt;"mysql_password"&lt;/span&gt; database_name &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; dbbackup.sql
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now chomd the script to allow it to for execution&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;chmod&lt;/span&gt; +x ~/scripts/db_backup.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 2: Creating the shell script which sync the backups with Amazon S3
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;nano db_sync.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Copy and paste the script below to it&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#!/bin/bash
/usr/local/bin/aws s3 sync ~/db_backups s3://my-bucket-name
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now chmod the script to allow it for execution&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;chmod +x ~/scripts/db_sync.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 3: Creating the folder in Amazon S3 for the database dumps
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd ~
mkdir db_backups
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 4: Time to configure the AWS CLI
&lt;/h3&gt;

&lt;p&gt;Before installing the AWS CLI you need to install&lt;code&gt;python-pi&lt;/code&gt;. Type the following commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apt-get update
apt-get -y install python-pip
curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html"&gt;Install the AWS CLI&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Type the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install awscli
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 5: Time to set up AWS key &amp;amp; Secret
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html"&gt;Configuration and credential file settings&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NyualHXI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://simplebackups.io/images/uploads/image2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NyualHXI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://simplebackups.io/images/uploads/image2.png" alt="" width="796" height="397"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd ~
mkdir .aws
nano ~/.aws/config
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Paste in &lt;code&gt;key_id&lt;/code&gt;and &lt;code&gt;secret_access_key&lt;/code&gt; as shown below&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[default]
aws_access_key_id=AKIAIOSFODNN7EXAMPLE
aws_secret_access_key=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 6: Set up the Cron (to automate the process)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;crontab -e
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Paste the below commands at the bottom to automate the process&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;0 0 * * * ~/scripts/db_backup.sh # take a backup every midnight
0 2 * * * ~/scripts/db_sync.sh # upload the backup at 2am
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This way the backup script will run and also sync with Amazon S3 daily.&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;Hence, by using these scripts you can achieve 3 goals:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Creating the database backup via a shell script&lt;/li&gt;
&lt;li&gt;uploading the dump to Amazon S3&lt;/li&gt;
&lt;li&gt;also automating this process using Cron.&lt;/li&gt;
&lt;/ol&gt;




&lt;p&gt;&lt;em&gt;Have you tried &lt;a href="https://simplebackups.io/?ref=blog"&gt;SimpleBackups.io &lt;/a&gt; yet?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;SimpleBackups will save you a lot of time setting up scripts and ensuring they run without problems. It will alert you when things go wrong, and allows you store your backups on many cloud storage services like Google, DigitalOcean, Wasabi, Dropbox, and more…&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8pRDJsz---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://simplebackups.io/images/uploads/simplebackups-bringstorage.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8pRDJsz---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://simplebackups.io/images/uploads/simplebackups-bringstorage.png" alt="" width="800" height="543"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>mysql</category>
      <category>mariadb</category>
      <category>bash</category>
      <category>database</category>
    </item>
  </channel>
</rss>
