The following shell script backups up the currrent node project by performing the following actions:
- Assumes that the back script is bundled with the actual NodeJS projecxt foler.
- Uses the current directory as the backup file name.
- Moves to the parent folder to create a tarball using the project name and the current date stamp and excludes the node_modules folder.
- Lists the backups created using the script.
#!/bin/sh
projectName=${PWD##*/}
cd ..
d=`date +%Y%m%d-%H%M%S`
fname=''${projectName}-$d.tgz
tar pczf $fname --exclude *.log --exclude node_modules ${projectName}
ls -lrt ${projectName}*.tgz
Given a folder called my-cool-project
, the created backup would look like this, and would sit in the folder outside of the my-cool-project directory.
my-cool-project-20160707-105046.tgz
Just use Github to tag builds? Sure you should be doing that anyway! The above script is intended to grab the project along with configuration files you might need to backup. Normally you wouldn't store your production config files in your project repo - particularily if PKI certs are involved.