Results 1 to 5 of 5

Thread: How to take a backup in MariaDB on Ubuntu 20.04?

  1. #1
    Join Date
    Sep 2023
    Beans
    2

    How to take a backup in MariaDB on Ubuntu 20.04?

    Hello everyone,
    I apologize if I'm in the wrong forum. I'm trying to take a backup of my SQL database which is on MariaDB but I'm at a loss. I've tried the commands I see on the internet but everytime I press enter I am presented with another line that looks like this

    -->

    These are the commands I run from a terminal

    sudu su <-- To get SU

    mysql -u root -p <-- I can only successfully run this command if I use sudo su (I am not logged on as root but as another administrator


    mysqldump -u root -p <-- Logs into MariaDB

    SHOW DATABASES; <-- Shows my databases

    mysqldump -u root -p myDBName > /home/myusername/DB_backup.sql

    When I press enter on the last line it just skips to the next line with a

    -->

    As if it's waiting for some kind of input. Am I doing something wrong?

    Thanks

  2. #2
    Join Date
    Apr 2014
    Location
    Tucson AZ, USA
    Beans
    1,085
    Distro
    Ubuntu

    Re: How to take a backup in MariaDB on Ubuntu 20.04?

    I can't see your exact problem. Code tags help. That being said this is the script I use to dump my docker mariadb daily. Hasn't let me down yet. I haven't tested the restore part of the script. I do know my sqldumps restore as I had to reload one awhile back, just manually did the one.

    https://gitlab.com/jmgibson1981/homescripts/-/blob/master/miscscripts/sqldumprestore.sh?ref_type=heads


    *EDIT* Correction.

    Code:
    mysqldump -u root -p  myDBName > /home/myusername/DB_backup.sql
    This needs to be run from the terminal, not inside the sql shell.
    Last edited by Tadaen_Sylvermane; September 26th, 2023 at 07:23 PM.

  3. #3
    Join Date
    Sep 2023
    Beans
    2

    Re: How to take a backup in MariaDB on Ubuntu 20.04?

    Hello, I honestly have no idea what is different from what you wrote and what I have. I even put them side by side to compare and they are identical.
    Whatever it is it works now, my DB is backed up.
    Thanks though!

  4. #4
    Join Date
    Mar 2010
    Location
    Squidbilly-Land
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: How to take a backup in MariaDB on Ubuntu 20.04?


  5. #5
    Join Date
    Dec 2014
    Beans
    2,658

    Re: How to take a backup in MariaDB on Ubuntu 20.04?

    To make the difference between what you're doing and what Tadaen_Silvermane describes clear: you're entering the 'mysqldump' command into the SQL shell (/usr/bin/mysql). 'mysqldump' isn't a command in the SQL shell, it's a separate program and should be entered on the normal command line. SQL queries end in a ';' - it's done that way so you can easily enter multi-line queries. The '->' you see is the secondary prompt telling you to continue entering your query. If you had typed a ';' at the '->' prompt you would have gotten an error message telling you that the mysql shell doesn't know what to do with your input.

    Holger

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •