@spongex/backup-scripts
v2.0.1
Published
Full system and folder backup scripts
Downloads
1
Readme
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.
Changelog
2.0.1
- Bump packages and relocated project on GitHub
- Updated project name to proper NPM formatting