GithubHelp home page GithubHelp logo

atomicsponge / backup_scripts Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 72 KB

๐Ÿ”„ System and Local NodeJS Backup Scripts

Home Page: https://www.npmjs.com/package/@spongex/backup_scripts

License: MIT License

JavaScript 100.00%
backup backup-scripts nodejs script

backup_scripts's Introduction

Backup NodeJS Scripts

Local and system backup scripts. See each section for usage of each script.

Install globally:

npm i -g @spongex/backup_scrips

Or per-project as a dev-dependency:

npm i @spongex/backup_scrips --save-dev

Local Backup

Command: npx localbak

Create a local _backup folder and copy the current folder to the new one.

Allows for certain files and folders to be ignored. In the running folder, create a file called .localbak_config.json with the following format:

{
  "ignore": [
    ".cmake",
    ".git",
    "build",
    "docs",
    "node_modules"
  ]
}

System Backup

Command: npx sysbak

Does heavy command injection, use at your own risk!

See NodeJS's documentation on exec for more information on how commands work.

Use a third party sync utility such as rclone and automate folder syncronization.

To use, define a command to run a sync utility and a list of jobs in a _config.json file located in a .sysbak folder placed in your user home directory.

Two variables are required to be defined:

  • "backup_command" - The sync command to run. The script can replace variables defined in this command.
  • "jobs" - An array of job objects to run. Each job should have a name and location item.

An exampe format is as follows:

{
  "backup_command": "rclone --log-file=$LOG_LOCATION/$JOB_NAME.log --log-level $LOGGING_LEVEL --skip-links --ask-password=false --password-command $RCLONE_PASSWORD_COMMAND sync $JOB_LOCATION $BACKUP_NAME:$JOB_NAME",
  "jobs": [
    {
      "name": "Backup",
      "location": "/home/matthew/Backup"
    },
    {
      "name": "Documents",
      "location": "/home/matthew/Documents"
    },
    {
      "name": "Music",
      "location": "/home/matthew/Music"
    },
    {
      "name": "Pictures",
      "location": "/home/matthew/Pictures"
    },
    {
      "name": "Projects",
      "location": "/home/matthew/Projects"
    },
    {
      "name": "Videos",
      "location": "/home/matthew/Videos"
      "vars" {
        {
          "variable": "$EXAMPLE",
          "value": "this is only an example!"
        }
      }
    }
  ],
  "cmdVars": [
    {
      "variable": "$LOGGING_LEVEL",
      "value": "NOTICE"
    },
    {
      "variable": "$RCLONE_PASSWORD_COMMAND",
      "value": "\"pass rclone/config\""
    },
    {
      "variable": "$BACKUP_NAME",
      "value": "backup_crypt"
    }
  ]
}

The script has the following command variables pre-defined:

  • $JOB_NAME - The name of the job from the job object
  • $JOB_LOCATION - The location of the job from the job object
  • $LOG_LOCATION - The location of the log files

Additional options

Additional variables can be defiend for replacement in the backup_command. Either with an optional "cmdVars" array or a "vars" array defiend in each job. Each command is an object that requires a "variable" and "value" item. See the above example for details.

Each job object can also have a backup_command item that will overwrite the global defiend one.

backup_scripts's People

Contributors

atomicsponge avatar

Stargazers

 avatar  avatar

Watchers

 avatar

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.