nosbackup
v1.0.6
Published
A CLI application that allows you to backup what you want and when you want from your PC/server to Dropbox, NOSBackup uses streams and chunks in order to handle big data.
Downloads
13
Maintainers
Readme
NOSBackup
For more comprehensive solution please take a look at ServerBackup
A CLI application that allows you to backup what you want and when you want from your PC/server to Dropbox, NOSBackup uses streams and chunks in order to handle big data.
Table of Contents
Documentation
Requirements
- First, make sure you have the latest version of Node.js installed.
- Create a Dropbox app from here and save its access token to use it later with NOSBackup.
- Create four folders in your Dropbox app folder with these names:
manually
,daily
,weekly
, andmonthly
. - NOSBackup relies on
mysqldump
andmongodump
to backup MySQL and MongoDB databases, so make sure these tools are installed if you are planning to backup these databases.
Installation
Run:
npm install nosbackup -g
How to use it?
Go to an empty folder that you have permissions to write into it and run:
nosbackup b now
How it works
NOSBackup needs two files in the directory that you run it within it, these files are nosbackup.config.json
and nosbackup.destinations.json
, so when you run it for the first time it will ask you to create these configurations and destinations files then it will be able to continue.
NOSBackup currently able to create a daily, weekly, monthly and manually backups, the manual backup is the backup that you can create manually at any time without a schedule.
nosbackup.config.json
NOSBackup uses this file to save its configurations, here is a sample of this file:
{
"accessToken": "your-dropbox-app-access-token",
"monthlyLimit": 4,
"weeklyLimit": 4,
"dailyLimit": 30,
"backupAtHour": 4,
"backupAtMinute": 30
}
You can create this file manually by using any text editor or you can let NOSBackup generates it for you, here is what every configuration means:
- accessToken: (String) Your Dropbox app access token.
- monthlyLimit: (Number) How many backups should remain in the
monthly
folder, when this number reached and NOSBackup wants to create a new backup it will delete the oldest backup first. - weeklyLimit: (Number) How many backups should remain in the
weekly
folder, when this number reached and NOSBackup wants to create a new backup it will delete the oldest backup first. - dailyLimit: (Number) How many backups should remain in the
daily
folder, when this number reached and NOSBackup wants to create a new backup it will delete the oldest backup first. - backupAtHour: (Number) At which hour(24-hour clock) you want this backup to run.
- backupAtMinute: (Number) At which minute you want this backup to run.
nosbackup.destinations.json
NOSBackup uses this file to save the destinations, here is a sample of this file:
[
{
"type": "fileDownload",
"fileToDownload": "/daily/2018-01-02-0103/name_2018-01-02-0103.zip",
"fileToDownloadTo": "/home/mohammed/Documents/Tmp/20/name_2018-01-02-0103.zip"
},
{
"type": "filesDownload",
"folderToDownloadFrom": "/daily/2018-01-02-0103",
"folderToDownloadTo": "/home/mohammed/Documents/Tmp/21"
},
{
"type": "files",
"archive": true,
"path": "/media/mohammed/My Passport/Dropbox/htdocs/my-files",
"name": "my-files"
},
{
"type": "files",
"archive": false,
"path": "/media/mohammed/My Passport/Dropbox/Pictures/"
},
{
"type": "file",
"path": "/media/mohammed/My Passport/Dropbox/Pictures/featured.jpg"
},
{
"type": "mySQL",
"DbName": "tajer",
"DbUser": "root",
"DbPassword": ""
},
{
"type": "mySQL",
"DbName": "NosBackupTest",
"DbUser": "root"
},
{
"type": "mongoDB",
"DbName": "Nos"
}
]
You can create this file manually using any text editor or you can let NOSBackup generate it for you.
The destinations are self-explained, you can have as many destinations as you want, the destinations will run sequentially for many reasons, here is an explanation for these destinations:
- fileDownload: In this destination you have a file in your Dropbox folder app and you want to download it, the
fileToDownload
is the file that you want to download andfileToDownloadTo
is where you want to download this file to. - filesDownload: In this destination you have a bunch of files in a folder in your Dropbox folder app and you want to download them, the
folderToDownloadFrom
is the folder that you want to download these files from it andfolderToDownloadTo
is where you want to download these files to. - files: In this destination you have a bunch of files in a local folder and you want to upload them to your Dropbox folder app, you can archive them(zip them) then upload them or you can upload them as they, just specify where these files are in
path
and whether you want to archive them or not inarchive
and give then a unique name inname
. - file: In this destination you have a file in a local folder and you want to upload it to your Dropbox folder app, just specify where this file live in
path
. - mySQL: In this destination you have a MySQL database and you want to back it up and upload it to your Dropbox folder app.
- mongoDB: In this destination you have a MongoDB database and you want to back it up and upload it to your Dropbox folder app.
Commands
Usage: nosbackup [options] [command]
PC/Server backup CLI app to backup to Dropbox using streams and chunks to handle big data.
Options:
-V, --version output the version number
-h, --help output usage information
Commands:
configurations|c Reset the configurations
destinations|d Reset destinations
backup|b [now] Backup, using the existing configurations and destinations, or create them if they do not exist.
For example you can run:
nosbackup b
or
nosbackup backup
To run the backup and create the configurations and destinations files if they do not exist.
This option will run the backup in schedule mode, if you want to run the backup immediately you can run:
nosbackup b now
or
nosbackup backup now
To create/recreate the configurations file run:
nosbackup c
or
nosbackup configurations
To create/recreate the destinations file run:
nosbackup d
or
nosbackup destinations
To get help run:
nosbackup -h
or
nosbackup --help
Questions
How to daemonized, monitor and keep NOSBackup alive forever.
There are a lot of tools, however, you can use PM2 to achieve that.
First install PM2 by running
npm install pm2 -g
Create
ecosystem.config.js
file in the folder that you specified for NOSBackup(must have write permissions) with the following content:module.exports = { apps: [{ name: 'NOSBackup', script: 'nosbackup', cwd: '/path/to/this/folder/', args: 'b' }] };
Please replace
/path/to/this/folder/
with the folder path.Run
pm2 start ecosystem.config.js
in the same folder.To stop and delete the process(undo the above step) you can run
pm2 delete NOSBackup
Support
This app built to run on Linux PCs/servers, so it may or may not work on your PC, please only report an issue if you run a Linux based operating system, unfortunately, I will not be able to test and reproduce the issue in order to fix it on the other platforms.
You are welcome to contribute code and provide pull requests for NOSBackup, also please feel free to suggest or request any features or enhancements.
License
Copyright (c) 2018 Mohammed Al-Mahdawi Licensed under the MIT license.