-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 9f45cef
Showing
20 changed files
with
3,475 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_modules/ | ||
/dist/ | ||
/dev/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"root": true, | ||
"extends": [ | ||
"eslint:recommended", | ||
"plugin:@typescript-eslint/recommended", | ||
"prettier" | ||
], | ||
"parser": "@typescript-eslint/parser", | ||
"parserOptions": { | ||
"project": "./tsconfig.json" | ||
}, | ||
"plugins": [ | ||
"@typescript-eslint" | ||
], | ||
"rules": { | ||
"eqeqeq": 2, | ||
"no-duplicate-imports": "error", | ||
"indent": ["error", 2], | ||
"linebreak-style": ["error", "unix"], | ||
"quotes": ["error", "single"], | ||
"semi": ["error", "never"] | ||
}, | ||
"env": { | ||
"node": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
* text=auto eol=lf | ||
/dist/* -diff linguist-generated=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ko_fi: szapp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: build | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
pull_request: | ||
branches: [main] | ||
|
||
jobs: | ||
lint: | ||
name: lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
- run: npm ci | ||
- run: npm run lint | ||
|
||
build: | ||
name: build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
- run: rm -rf dist | ||
- run: npm ci | ||
- run: npm run build | ||
- run: npm pack --dry-run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules/ | ||
/dev/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/node_modules/ | ||
/.* | ||
/src/ | ||
/dev/ | ||
/tsconfig.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/node_modules/ | ||
/dist/ | ||
/dev/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"semi": false, | ||
"singleQuote": true, | ||
"singleAttributePerLine": true, | ||
"trailingComma": "es5", | ||
"bracketSpacing": true, | ||
"arrowParens": "always", | ||
"printWidth": 140, | ||
"endOfLine": "lf" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"files.eol": "\n", | ||
"editor.formatOnPaste": false, | ||
"editor.formatOnSave": true, | ||
"editor.formatOnType": false, | ||
"editor.defaultFormatter": "esbenp.prettier-vscode", | ||
"editor.codeActionsOnSave": { | ||
"source.fixAll.eslint": "never", | ||
"source.fixAll.format": "never" | ||
}, | ||
"typescript.tsdk": "./node_modules/typescript/lib" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 Sören Zapp | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
# Filen Snapshot | ||
|
||
[](https://github.com/szapp/filen-snapshot/actions/workflows/build.yml) | ||
|
||
Create simple snapshots to back up your files and directories in your Filen.io drive | ||
|
||
## Features | ||
|
||
Simple backup tool that copies one or several directory trees into a designated directory to serve as a snapshot in time. | ||
|
||
There is no functionality beyond the automated copy process. | ||
This package can be setup locally to run on a schedule. | ||
|
||
## Usage | ||
|
||
Install | ||
|
||
``` | ||
npm install szapp/filen-snapshot | ||
``` | ||
|
||
Import | ||
|
||
```typescript | ||
// JavaScript | ||
const createSnapshot = require('filen-snapshot') | ||
// TypeScript | ||
import createSnapshot from 'filen-snapshot' | ||
``` | ||
|
||
Use | ||
|
||
```typescript | ||
await createSnapshot({ | ||
email: 'filen-user@example.com', // Filen account email | ||
password: 'filen-password', // Filen account password | ||
twoFactorCode: '123456', // Two-factor authentication TOTP (if enabled and twoFactorSecret is not specified) | ||
twoFactorSecret: 'JFSU4NNSFGFLOPL2' // Two-factor authentication secret (if enabled and twoFactorCode is not specified) | ||
localPath: 'C:/Users/Admin/Filen/' // Local path to Filen (if available, allows faster backups by uploading local files instead of downloading and uploading cloud files) | ||
source: ['/Documents/Important/', '/Documents/Work/', '/Photos/'] // Source directories (one or several paths relative to the root directory of the Filen drive) | ||
destination: '/Snapshots/' // Snapshot directory (relative to the root directory of the Filen drive, in which the snapshot will be created) | ||
snapshotName: 'yyyy-MM-dd_HH.mm.ss' // Default: 'yyyy-MM-dd_HH-mm-ss' (name of the snapshot directory, formatted with Luxon.DateTime.toFormat) | ||
}) | ||
``` | ||
|
||
Mind that the login information is exposed if entered into the node REPL. | ||
A more secure alternative is to store the arguments safely to disk and provide a path to the JSON file. | ||
|
||
```typescript | ||
await createSnapshot('path/to/config.json') | ||
``` | ||
|
||
The code above will result in the following directory backup: | ||
|
||
``` | ||
Filen drive/ | ||
├── Documents/ | ||
├── Photos/ | ||
├── ... | ||
└── Snapshots/ | ||
├── ... | ||
└── 2024-03-16_23.10.45/ | ||
├── Documents/ | ||
│ ├── Important/ | ||
│ └── Work/ | ||
└── Photos/ | ||
``` | ||
|
||
## Usage without knowledge of Node.js | ||
|
||
1. Download and install [`nvm`](https://github.com/nvm-sh/nvm) (or [`nvm for windows`](https://github.com/coreybutler/nvm-windows)) | ||
2. Install the latest node version and npm | ||
```bash | ||
nvm install latest && nvm use latest | ||
``` | ||
(Possibly restart your terminal) | ||
3. Install this package | ||
```bash | ||
npm install -g szapp/filen-snapshot | ||
``` | ||
(Possibly restart your terminal) | ||
4. Create JavaScript file `runSnapshot.js` and adjust the following content | ||
```javascript | ||
const createSnapshot = require('filen-snapshot') | ||
async function main() { | ||
await createSnapshot({ | ||
email: 'filen-user@example.com', // Filen account email | ||
password: 'filen-password', // Filen account password | ||
twoFactorCode: '123456', // Two-factor authentication TOTP (if enabled and twoFactorSecret is not specified) | ||
twoFactorSecret: 'JFSU4NNSFGFLOPL2' // Two-factor authentication secret (if enabled and twoFactorCode is not specified) | ||
localPath: 'C:/Users/Admin/Filen/' // Local path to Filen (if available, allows faster backups by uploading local files instead of downloading and uploading cloud files) | ||
source: ['/Documents/Important/', '/Documents/Work/', '/Photos/'] // Source directories (one or several paths relative to the root directory of the Filen drive) | ||
destination: '/Snapshots/' // Snapshot directory (relative to the root directory of the Filen drive, in which the snapshot will be created) | ||
snapshotName: 'yyyy-MM-dd_HH.mm.ss' // Default: 'yyyy-MM-dd_HH-mm-ss' (name of the snapshot directory, formatted with Luxon.DateTime.toFormat) | ||
}) | ||
} | ||
main() | ||
``` | ||
5. Run from terminal with | ||
```bash | ||
node runSnapshot.js | ||
``` | ||
|
||
## Details | ||
|
||
- Because of the encryption there is no simple copy functionality in the cloud. | ||
All files will be decrypted downloaded and uploaded into the snapshot directory. | ||
This will be quite a slow process and demanding on traffic and possibly unsafe (depending on the use of the local machine). | ||
A safer alternative is to provide the `localPath` to the Filen drive on the computer (if available). | ||
The files will then be uploaded directly which is much faster. | ||
Note that in both cases, the files are copied directly into the cloud and the snapshot directory does not have to be synced locally. | ||
|
||
- Use at your own risk. | ||
The Filen SDK is still under active development and not meant for production. | ||
Although the logic of this package here is very concise, it was not thoroughly tested. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.