Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added BACKUP_DIR env for conf.yml backups #1326

Merged
merged 1 commit into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,6 @@

# Again, set automatically using package.json during build time
# VUE_APP_VERSION=2.0.0

# Directory for conf.yml backups
# BACKUP_DIR=./public/
1 change: 1 addition & 0 deletions docs/developing.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ You can set variables either in your environment, or using the [`.env`](https://
- `INTEGRITY` - Should enable SRI for build script and link resources
- `IS_DOCKER` - Computed automatically on build. Indicates if running in container
- `VUE_APP_VERSION` - Again, set automatically using package.json during build time
- `BACKUP_DIR` - Directory for conf.yml backups

### Environment Modes

Expand Down
4 changes: 3 additions & 1 deletion services/save-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* Finally, it will call a function with the status message
*/
const fsPromises = require('fs').promises;
const path = require('path');

module.exports = async (newConfig, render) => {
/* Either returns nothing (if using default path), or strips navigational characters from path */
Expand All @@ -24,7 +25,8 @@ module.exports = async (newConfig, render) => {
};

// Make the full file name and path to save the backup config file
const backupFilePath = `${settings.defaultLocation}${usersFileName || settings.filename}-`
const backupFilePath = path.normalize(process.env.BACKUP_DIR || settings.defaultLocation)
+ `/${usersFileName || settings.filename}-`
+ `${Math.round(new Date() / 1000)}${settings.backupDenominator}`;

// The path where the main conf.yml should be read and saved to
Expand Down