Skip to content

hariprasanths/synchly

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Synchly backups

version Node Version Documentation License: Apache-2.0

Description

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
    • PostgreSQL
  • Compression - Compress the database backups to save up space.
  • Cloud Storage Integration - Sync the local backups to remote storage of your choice.
  • Restoration - Restore the database from the backups.
  • Supported remote storages
    • Google Drive
    • SFTP
    • S3
  • 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.
  • Multiple Backup Jobs - Run multiple backup jobs in parallel.
  • Encryption - Encrypt the job configuration and backup files.

Prerequisites

  • node >=8

Installation

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

npm install --global synchly

or using yarn:

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

$ synchly [--config module]
$ synchly [--config module] [--file filepath]
$ synchly [--disablejob] [--job exampleJob]
$ synchly [--disable module] [--debug]
$ synchly [--enablejob] [--job exampleJob]
$ synchly [--enable module] [--stacktrace]
$ synchly [--help]
$ synchly [--job exampleJob] [--config module]
$ synchly [--jobs]
$ synchly [--reset]
$ synchly [--restore]
$ synchly [--run]
$ 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 synchly --config=db command.

To start synchly use the command synchly --start.
Synchly instance have to be restarted everytime you make a change to the configuration using the cli options.

To restore database from the backup files use the command synchly --restore.

Configuration of modules (remote-sync and smtp) can be added or updated using synchly --config=module command. Initializing configurations can also be done using a file, synchly --config=module --file=filepath, refer Configuration using file.

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

To encyrpt the job configuration files use the command synchly --enable=cipher and to disable it globally use the command synchly --disable=cipher. Encryption of backup files can be done only when cipher module is enabled.

For the complete list of options and their behavior, refer List of options.

For running synchly as a daemon, refer Running as a deamon.

For creating multiple backup jobs, refer Running multiple jobs

List of options

Option

Description

-c, --config=module

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

-D, --debug

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

--disablejob

Disable a job.
Use with option --job=NAME to disable the specific job NAME

-d, --disable=module

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

--enablejob

Enable a job.
Use with option --job=NAME to enable the specific job NAME

-e, --enable=module

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

-f, --file=filepath

Create or update module configuration using the specified file.
To be used with --config flag

-h, --help

Prints CLI reference information about options and their arguments

-j, --job

Create a new synchly job with the NAME (creates a job named 'master' by default if the option --job is not specified). This is useful for running multiple backup jobs in parallel

--jobs

Displays information about all the synchly jobs

--reset

Reset all the configurations saved

-R, --restore

Restore database from the backup

--run

Take a database backup forthwith

-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 all the enabled synchly jobs 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.

If installed using npm:

init.d

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

systemd

$ 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

Read our Contribution Guidelines for information on how you can help out Synchly

Show your support

Give a ⭐ if this project helped you!

License

Copyright ©️ 2020 Hariprasanth S

This project is licensed under the Apache License, Version 2.0
You may also obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0