OpenTibiaBR
GithubDiscordSponsor
  • Home
    • 📖Welcome!
    • 💵Donate
  • OpenTibiaBR
    • 🖥️Projects
      • 🐦Canary
        • About
        • Getting Started
          • Compiling
            • Linux
              • [Linux] Compiling Canary Sources
            • Windows
              • Visual Studio
                • [Windows][VC2022][CMake] Compiling Canary Sources
                • [Windows][VC2022][Solution] Compiling Canary Sources
              • WSL
                • [WSL] Compiling Canary Sources
          • Installing
            • aaPanel
              • [Linux] Canary + aaPanel + MyAAC
            • Docker
              • [Docker] Canary + MariaDB + MyAAC
            • Linux
              • Nginx + MariaDB + MyAAC
            • Windows
              • Uniform Server
                • [Windows][Basic] Canary + Uniform Server + MyAAC
              • XAMPP
                • [Windows][Advanced] Canary + XAMPP + MyAAC
        • Tutorials
          • Basic
            • Auto Backup Server Database
            • Auto Restart and Linux Logs
            • Custom Bestiary / Prey with Canary Monster Editor
            • Event Schedule Canary / OTServBR-Global
            • How to make a custom server with Canary
            • How to reset players in your database
            • How to secure a Linux server
            • SSL Certificates
            • Webhook Discord
            • [Outdated] Custom Bestiary / Prey
            • [Linux] Backup + Upload - Google Drive
            • [Linux] How to install Linux headers
            • VPS Linux
            • [Windows] SSL/HTTPS Certificate with XAMPP
          • Mapping
            • [Windows] Remere's Map Editor - Opening Canary / OTServBR-Global Map
            • [Windows] Remere's Map Editor - Converting map server id to client id
          • Programming & Scripting
            • How to add a new vocation
            • Revscriptsys
            • Guide Lua Objects
            • How to get raceId for monsters
          • Websites
            • [Canary][OTServBR-Global][GesiorAAC][MyAAC] Set up Initial Character
          • Miscellaneous
            • Useful Tutorials
            • Video Tutorials
      • 🗺️Remere's Map Editor
        • About
        • Getting Started
          • Linux
            • [Linux] Compiling Remere's Map Editor Sources
          • Windows
            • WSL
              • [WSL] Compiling Remere's Map Editor Sources
            • Visual Studio
              • [Windows][VC2022][CMake] Compiling Remere's Map Editor Sources
              • [Windows][VC2022][Solution] Compiling Remere's Map Editor Sources
      • 🎮OTClient Redemption
        • About
        • Getting Started
          • Android
            • [Android] Compiling OTClient Redemption Sources
          • Linux
            • [Linux] Compiling OTClient Redemption Sources
          • Windows
            • WSL
              • [WSL] Compiling OTClient Redemption Sources
            • Visual Studio
              • [Windows][VC2022][CMake] Compiling OTClient Redemption Sources
              • [Windows][VC2022][Solution] Compiling OTClient Redemption Sources
          • Web
            • [Web] OTClient Redemption
        • Tutorials
          • Basic
            • Client Updater
    • 🔗Downloads
      • 🎮Clients
        • Client 11
        • Client 14
          • Tutorials
            • Client with HexEditorXVI32
            • Client with Notepad++
            • Client with config.ini
            • [Windows] How to change client background
        • OTClientV8
          • About
          • Getting Started
            • Android
              • [Android] Compiling OTClientV8 Sources
            • Linux
              • [Linux] Compiling OTClientV8 Sources
            • Windows
              • WSL
                • [WSL] Compiling OTClientV8 Sources
              • Visual Studio
                • [Windows][VC2022][CMake] Compiling OTClientV8 Sources
                • [Windows][VC2022][Solution] Compiling OTClientV8 Sources
          • Features
            • Health and Mana bar backgrounds
            • HTTP support
            • OTML Improvement
            • Simple cam recorder and player
            • Updater, encryption and compression
            • WebSockets
        • Minimap
      • 📑Codes
        • C++
        • Events
        • Functions
        • Libs
        • Modules
        • Others
      • 🖼️Images
        • PSDs
        • Others
      • 🗺️Maps
        • Custom
        • Global
      • 📑Revscripts
        • Actions
        • CreatureEvents
        • GlobalEvents
        • MoveEvents
        • NPCs
        • Spells
        • Systems
        • TalkActions
      • ⚔️Sprites
      • ⚙️Tools
        • Editors
        • Launchers
          • Canary Launcher
            • About
            • Getting Started
              • Windows
                • [Windows][VC2022][Solution] Compiling Canary Launcher Sources
          • Slender Launcher
            • About
            • Getting Started
              • Windows
                • [Windows][Go] Compiling Slender Launcher Sources
        • Login Server
          • About
          • Getting Started
        • Map Generators
      • 🌐Web Packages
        • Linux
        • Windows
      • 🌐Website Applications
        • Websites
          • CanaryAAC
            • About
            • Informations
              • Features
              • Functions
              • API
              • Routes
              • Middleware
            • CanaryAAC Bot
          • Gesior2012
            • About
          • GesiorAAC Global
            • About
          • MyAAC
            • About
          • MyAAC Global
            • About
          • SlenderAAC
            • About
          • ZnoteAAC
            • About
        • Applications
        • Layouts
        • APIs and SDKs
Powered by GitBook
On this page
  • Tutorial explaining how to make for your database.
  • 1 - Let's see if the nano is installed on your Linux machine, run on the terminal:
  • 2 - Let's go the way where you want to save the script .sh can be anywhere of your choice, I will use the root directory of my server as an Example:
  • 3 - Now let's create the script.sh:
  • 4 - Let's give permission to the script created:
  • 5 - Now we put to run automatically as your choice, run on the Linux terminal the command:
  • 6 - Enter at the end of all some of the options:
  • 7 - Now just restart your Linux machine.
  1. OpenTibiaBR
  2. Projects
  3. Canary
  4. Tutorials
  5. Basic

Auto Backup Server Database

Tutorial explaining how to make for your database.

1 - Let's see if the nano is installed on your Linux machine, run on the terminal:

sudo apt install nano

2 - Let's go the way where you want to save the script .sh can be anywhere of your choice, I will use the root directory of my server as an Example:

cd /home/$USER/canary

In the above command the "daniel" represents my Linux user and "canary" the root folder of mine server.

3 - Now let's create the script.sh:

nano backup-database.sh
  • Then enter:

#!/bin/bash

path="/home/ubuntu/database-backup"     #Path where the backup of your database "Db
nameBackup="prod-oracle"                #Environment where is hosted
mysqlUser="XX"                          #Your MySQL user
mysqlPass="XX"                          #Your MySQL password
mysqlDatabase="XX"                      #The name of your database "Db

TIMER="$(date +'%d-%m-%Y-%H-%M')"

if [[ -z "$mysqlUser" || -z "$mysqlPass" || -z "$mysqlDatabase" ]]; then
    echo "Please fill in username, password and database in settings."
else
  # mysqldump -u$mysqlUser -p$mysqlPass $mysqlDatabase > $path"/"$nameBackup"-"$TIMER".sql" &&
    mysqldump -u$mysqlUser -p$mysqlPass $mysqlDatabase > $path"/"$nameBackup".sql" &&
    cd $path &&
    git add . &&
    git commit -m "Bkp uploaded automatically '$nameBackup'" &&
    git push &&
    echo "Backup Complete."
fi
  • Save with CTRL+X after Y and Enter.

4 - Let's give permission to the script created:

chmod +x backup-database.sh

5 - Now we put to run automatically as your choice, run on the Linux terminal the command:

crontab -e

Remember that "/home/daniel/backup-database.sh" is the director of my script so you'll have to change that part!

6 - Enter at the end of all some of the options:

# between 05:00hrs and 23:00hrs
0 5,23 * * * sh /home/daniel/backup-database.sh
# 1 in 1 hour
0 */1 * * * sh /home/daniel/canary/backup-database.sh
# 5 in 5 minutes:
*/5 * * * * sh /home/daniel/canary/backup-database.sh
  • Save with CTRL+X after Y and Enter.

7 - Now just restart your Linux machine.

Credits: Beats.

Last updated 1 year ago

🖥️
🐦