Click here to Skip to main content
15,881,089 members
Articles / Database Development / MongoDB
Article

Automate Database Backups with Customizable Recurring Schedules

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
1 Jul 2020Apache3 min read 5K   2  
A CLI to automate database backups with customizable recurring schedules
Features like cloud storage integration, flexible scheduling of backups, status notifications, compression makes the process of automating database backups a breeze.

Introduction

CLI to automate database backups with customizable recurring schedules.

Features

  • Backup scheme - Synchly uses a Grandfather-father-son backup rotation scheme (daily, weekly, monthly) that is fully customizable.
    Default schedule: 7 dailies + 8 weeklies + 6 monthlies (at max, there will be 21 backups at a given instant).
  • Flexible scheduling - Schedule the daily backups to fit your maintenance and development schedule, so that you get a clear picture of your database backups over time
  • Supported Databases
    • MySQL
    • MongoDB
  • Compression - Synchly compresses the database backups to save up space.
  • Cloud Storage Integration - Sync the local backups to remote storage of your choice.
  • Supported remote storages
    • Google Drive
    • SFTP
  • Status notifications** - Get daily status reports for successful and failed backups, delivered when you want them via SMTP to the specified email(s). Check Usage and the List of Options below.

Prerequisites

  • node >=8

Installation

The Synchly CLI is distributed as an NPM package. To use it, install it globally using:

Bash
npm install --global synchly

or using yarn:

Bash
yarn global add synchly

Tab Completion

The synchly package includes a useful tab-completion feature. This feature is installed automatically after the installation of the package. However, you might need to restart the console after installing the package for the autocomplete feature to work.

If you use Bash, it will create a file at ~/.synchly/completion.sh and append a loader code to ~/.bash_profile file.

If you use Zsh, it appends a loader code to ~/.zshrc file.

If you use Fish, it appends a loader code to ~/.config/fish/config.fish file.

Usage

Bash
$ synchly [--config module] 
$ synchly [--disable module] 
$ synchly [--enable module] [--stacktrace] 
$ synchly [--help] 
$ synchly [--reset] 
$ synchly [--start] 
$ synchly [--version]

Quick Setup

Synchly can be run with `--help` flag to get a full list of flags.

The quickest way to get started is to run the command:

Bash
synchly --config=db

To start synchly, use the command:

Bash
synchly --start

Synchly instance has to be restarted everytime you make a change to the configuration using the cli options. Configuration of modules (remote-sync and smtp) can be added or updated using the command:

Bash
synchly --config=module

By default, remote-sync and smtp modules are disabled, to enable them, use the command.

Bash
synchly --enable=module

For the complete list of options and their behavior, refer to the List of options below. For running synchly as a daemon, refer Running as a deamon section below.

List of Options

Option Description
-c, --config=module

Create or update module configuration.
Allowed modules: db | remote-sync | smtp

-d, --disable=module

Disable a module.
Allowed modules: remote-sync | smtp

-D, --debug

Prints even more information from CLI operations, used for debugging purposes

-e, --enable=module

Enable a module.
Allowed modules: remote-sync | smtp

-h, --help

Prints CLI reference information about options and their arguments

--reset

Reset all the configurations saved

-S, --stacktrace

Prints even more information about errors from CLI operation, used for debugging purposes. If you find a bug, provide output generated with the --stacktrace flag on when submitting a bug report

--start

Start synchly instance which logs to stdout and stderr

-v, --version

Display version information and exit

Running as a Daemon

Synchly can be run as a daemon, init.d and systemd unit files are bundled with the npm package to make this easier. aIf installed using npm:

init.d

Bash
$ npm install --global synchly
$ sudo cp /usr/local/lib/node_modules/synchly/bin/synchly.conf /etc/init 
$ sudo start synchly 

systemd

Bash
$ npm install --global synchly 
$ cp /usr/local/lib/node_modules/synchly/bin/synchly.service ~/.config/systemd/user/
$ systemctl --user enable synchly
$ systemctl --user start synchly

If the unit files are not there inside `/usr/local/lib/node_modules`, use `npm root -g` to get the global installation root path and copy the unit files from there. The `WorkingDirectory` field in the `synchly.service` unit file also needs to be changed, if the global installation root path is different from `/usr/local/lib/node_modules`.

If Installed Using yarn

If installed using yarn global, the service init files will be located on:

  • `/usr/local/share/.config/yarn/global/node_modules/synchly/bin/` - if logged in as root
  • `~/.config/yarn/global/node_modules/synchly/bin` - if logged in as non-root

NOTE: Don't forget to restart the daemon everytime you make a change to the configuration using the cli options.

Examples

Contributing

I'd love your help! If you have ideas for new features or feedback, let me know by creating an issue in the issues list.

License Notes

Copyright 2020 Hariprasanth S

History

  • 1st July, 2020: Initial version

License

This article, along with any associated source code and files, is licensed under The Apache License, Version 2.0


Written By
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
-- There are no messages in this forum --