Project

General

Profile

Actions

How to Backup Redmine Production Database on Ubuntu

It's important to note that the specific commands may vary depending on your setup and configuration, so it's always a good idea to double-check the details before running any commands. Overall, these instructions should help users successfully Backup a Redmine data base and files.

Log in to your server as a user with sudo privileges.

Open a terminal window.

Use the following command to navigate to the Redmine application directory:

cd /var/www/redmine
or
cd /opt/redmine

Use the following command to view the database configuration file:

cat config/database.yml

Look for this:
production:
adapter: mysql2
database: redmine_production
host: localhost
username: root
password: mypassword

Make a note of the, database: username: password:

Log in to MySQL server as root

sudo mysql -u root -p

Check the list of databases

SHOW DATABASES;

this is what I see,

MariaDB [(none)]> SHOW DATABASES;
+---------------------+
| Database            |
+---------------------+
| information_schema  |
| mysql               |
| performance_schema  |
| redmine_development |
| redmine_production  |
| redmine_test        |
+---------------------+
6 rows in set (0.001 sec)

As you can see the Database I am looking for is redmine_production, yours might be different.

Grant privileges to redmine user on my redmine_production database

GRANT ALL PRIVILEGES ON <your_database_name>.* TO 'redmine'@'localhost';

GRANT ALL PRIVILEGES ON redmine_production.* TO 'redmine'@'localhost';

NOTE: if you get this Error - ERROR 1133 (28000): Can't find any matching row in the user table ERROR 1133 (28000): Can't find any matching row in the user table
do this

CREATE USER 'redmine'@'localhost' IDENTIFIED BY 'your_password';

Flush the privileges to ensure that the changes take effect:

FLUSH PRIVILEGES;

Exit MySQL prompt

exit;

Create backup folder

sudo mkdir -p /root/backups

Create backup of redmine_production database

mysqldump -u <username> -p<password> -h <hostname> <redmine_database> > /path/to/backup/db/redmine.sql

In my Case it look like this...

mysqldump -u redmine -p7a60885acb1fb112083bca67e1b13023 redmine_production > /root/backups/redmine_production_backup.sql

NOTE: adding $(date +\%Y-\%m-\%d) to the file name will add today date, so it would look like this

/root/backups/redmine_production_backup_$(date +\%Y-\%m-\%d).sql

Add this to copy the files,

sudo rsync -a /var/www/redmine/files /root/backups/redmine_files

Install FileBrowers

Easy way to download the backup is to use FileBrower

apt install curl
curl -fsSL https://raw.githubusercontent.com/filebrowser/get/master/get.sh -o get.sh && chmod +x get.sh && ./get.sh

Start FileBrowser using the following command, replacing the IP address with the IP address you want to use:

filebrowser -a <IP address>

Use a web browser to navigate to the IP address and port :8080, for example, 192.168.1.65:8080.

Log in to FileBrowser using the default login (admin for both the username and password) and change the password immediately.

Download the backup file from the FileBrowser interface.

Updated by Gareth Eaton 11 months ago · 14 revisions