Git Product home page Git Product logo

postgresql-backup's Introduction

Database Backup

Database backup is a java system for generate PostgreSQL and Mysql backups. This is a linux documentation to install, schedulle and run the jar file for generate your backups.

Technologies

  • Java
  • PostgreSQL
  • Mysql
  • Cron

Usage the Project

With eclipse

  • Clone the project
  • Eclipse: File -> Import -> Maven -> Existing Maven Projects
  • Select the project folder
  • Run the class Bootstrap.java

Jar Packing

Use the fatjar plugin to pack the jar file, adding all libs just one jar. See the link below to know more about fat jar

Jar Install

Create the folders

$ mkdir /etc/database_backup
$ mkdir /opt/backups

Move the generated file database_backup.jar to folder /etc/database_backup

$ mv {your compiled jar} /etc/database_backup

Example: 

$ mv /opt/database_backup.jar /etc/database_backup

If you wish, download the compiled jar file: database_backup-1.7.jar

$ wget https://github.com/fabriciojf/postgresql-backup/releases/download/1.7/database_backup-1.7.jar

Execute the jar file to create a initial configuration at /etc/database_backup folder

$ java -jar /etc/database_backup/database_backup.jar 

See the file models

  • register - use this file to register your databases to backup.
  • settings - use this file to register a folder to alocate your backups.

Configuring Database

Edit the file /etc/database_backup/register adding the database configurations following the role:

host database user pass label type[postgre ou mysql]

Example:

127.0.0.1 dbuser postgres XXXX== userdatabase postgre
127.0.0.1 cms root XXXX== cmsdatabase mysql
  • In the above example, first line is generating a PostgreSQL backup and below a Mysql Backup.
  • XXXX== is the encrypted password

Encrypting the password

To register a new backup in the register file is necessary to encrypt the password before. For this, follow the tip below.

Run the jar file passing the password, generating a new encrypted string.

$ java -jar /etc/database_backup/database_backup.jar PASSWORD

Change the register file introducing the encrypted password in the corresponding line.

If you wish, clean the terminal history with the command below.

$ history -c

Scheduling a Database-backup on Cron with crontab

Type crontab -e in the linux terminal.

$ crontab -e

Insert a call to database_backup.jar at the end of the file cron. In the case below, the backup will be generated all days at 23:00 o'clock.

0 23 * * * java -jar /etc/database_backup/database_backup.jar

Author

Fabricio S Costa - [email protected]

Linkedin: fabriciojf Site: fabriciojf

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.