I needed a simple utility script to search for files and then make copies of those files.
Teacup Backup works in two modes: "backup" and "restore". In the case of backup mode the script searches for files with given name and then encrypts found files and saves them to selected directory. In restore mode the script decrypts all previously saved files.
Teacup Backup also has the functionality of uploading files to an FTP server.
To run Teacup Backup you need software listed in section Technologies. Then you can modify the configuration file as needed (src/config.json
) and run the command:
/teacup-backup$ npm run start
More details below.
Before running the application fill the values in the src/config.json
configuration file according to your needs (this file will be then also copied into dist/config.json
).
{
"backupDirectory": "./backups",
"files": ["index.ts"],
"interval": 3600,
"log-level": "debug",
"mode": "backup",
"roots": ["C:\\"]
}
If you would like to send the backup to an FTP server, you can provide credentials and path to backup directory, for example:
{
"backupDirectory": "./backups",
"files": ["index.ts"],
"ftp": {
"directory": "backups/teacup-backup",
"enabled": true,
"host": "192.168.50.1",
"password": "Qwerty123/",
"user": "user"
},
"interval": 3600,
"log-level": "debug",
"mode": "backup",
"roots": ["D:\\"]
}
mode
- either"backup"
or"restore"
backupDirectory
- (relative) directory for storing backup files, recommended"./backups"
interval
- time interval in seconds, how often backups are to be performed, for example3600
roots
- root directories where to search for files to back upfiles
- array of files to find and backup; each element of array should be a filename or regex to filelog-level
- level of detail of displayed logs (severity of errors); recommended"info"
ftp
- contains object with credentials to the FTP server and the name of the directory:directory
- path to backup directory on FTPenabled
-true
to enable sending to FTP,false
otherwisehost
- IP to the FTP serveruser
- usernamepassword
- password
Once you have filled the config.json
, you can install the required dependencies and then run the script.
Install dependencies:
/teacup-backup$ npm install
Run the script:
/teacup-backup$ npm run start
If "restore"
mode is set in the configuration file, then all encrypted files in the "backupDirectory"
directory will be decrypted and restored.
Run the script:
/teacup-backup$ npm run start
You need following to run the script:
- Node.js (recommended v18.16.0) - used for running & building the project
Technologies & dependencies used in development:
- TypeScript - used as a development tool, it is not required to download any compilers besides project dependencies
- RxJS - because reactive code is awesome
- ... and more: basic-ftp, crypto-js, file-base64, find, lodash, prompt-sync, winston
Project is MIT licensed.