Skip to content

Commit

Permalink
Merge pull request #50 from simatec/multiplatform
Browse files Browse the repository at this point in the history
Multiplatform
  • Loading branch information
simatec authored Oct 16, 2018
2 parents a196d3b + f8a4339 commit 3d7b37b
Show file tree
Hide file tree
Showing 13 changed files with 167 additions and 32 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ Backitup is a backup solution that allows cyclical backup of an IoBroker install

## Changelog

### 0.3.6 (16.10.2018)
* (simatec) Fix Dropbox Backup
* (simatec) Fix Restore path for ownDir
* (simatec) Fix FTP and NAS path
* (simatec) Fix Access Token for dropbox

### 0.3.5 (03.10.2018)
* (simatec) Fix Translation
* (simatec) Fix Filename Suffix for Restore
Expand Down
21 changes: 20 additions & 1 deletion admin/index_m.html
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,18 @@
$('.copy').hide();
}
}).trigger('change');

$('#restoreSource').on('change', function () {
if ($(this).val() === 'NAS / Copy' && $('#cifsOwnDir').prop('checked')) {
$('.bkpType').show();
} else if ($(this).val() === 'FTP' && $('#ftpOwnDir').prop('checked')) {
$('.bkpType').show();
} else if ($(this).val() === 'Dropbox' && $('#dropboxOwnDir').prop('checked')) {
$('.bkpType').show();
} else {
$('.bkpType').hide();
}
}).trigger('change');
/*
if ($('#mySqlEnabled').prop('checked')) {
$('.tab-my-sql').show();
Expand Down Expand Up @@ -956,7 +968,7 @@
<div id="tab-dropbox" class="col s12 page">
<div class="row dropbox">
<div class="input-field col s12">
<input class="value" id="dropboxAccessToken" type="text">
<input class="value" id="dropboxAccessToken" type="password">
<label for="dropboxAccessToken" class="translate">Access token</label>
<span><a href="https://www.dropbox.com/developers/apps" target="_blank">dropbox.com</a></span>
</div>
Expand Down Expand Up @@ -1010,6 +1022,13 @@
</select>
<label for="restoreSource" class="translate">source type</label>
</div>
<div class="input-field col s11 m2 bkpType">
<select class="value" id="restoreType">
<option value="Minimal" class="translate">Minimal</option>
<option value="Total" class="translate">Total</option>
</select>
<label for="restoreType" class="translate">restore type</label>
</div>
</div>
<div class="row">
<ul class="collapsible root">
Expand Down
1 change: 1 addition & 0 deletions admin/words.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 2 additions & 5 deletions docs/de/backitup.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ Folgende Schritte sollten durchgeführt werden um den Adapter verwenden zu könn
- CIFS:
- CIFS-Mount ist unter Linux kein Problem.
- Es sollte beachtet werden, dass cifs-utils installiert ist
- Die Pfadangabe unter CIFS muss immer ohne "/" beginnen (Bsp: "Freigabename/Pfadangabe")
- Die Pfadangabe sollte wie folgt aussehen (Bsp: "/Freigabename/Pfadangabe")
- Optional kann man aktivieren/deaktivieren, ob die Backups vom NAS gelöscht werden sollen
- NFS:
- NFS-Mount ist unter Linux kein Problem.
- Es sollte beachtet werden, dass nfs-common installiert ist
- Die Pfadangabe unter NFS muss immer ohne "/" beginnen (Bsp: "Freigabename/Pfadangabe")
- Die Pfadangabe sollte wie folgt aussehen (Bsp: "/Freigabename/Pfadangabe")
- Optional kann man aktivieren/deaktivieren, ob die Backups vom NAS gelöscht werden sollen
- FTP:
- FTP ist auf allen OS möglich und dient als eine Alternative zum CIFS Mount
Expand Down Expand Up @@ -196,7 +196,4 @@ Hier eine Liste der bisher aufgetretenen Probleme und deren Lösungen sofern vor

2. Sollte der CIFS-Mount mit IP-Adresse nicht möglich sein, sollte der Hostname des NAS verwendet werden

3. Kein FTP Connect möglich: Die Schreibweise der Pfadangabe prüfen (Bsp: "/Pfadangabe/minimal")

4. Kein CIFS-Mount möglich: Die Schreibweise der Pfadangabe prüfen (Bsp: "Freigabename/Pfadangabe")

10 changes: 3 additions & 7 deletions docs/en/backitup.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ The following steps should be used to use the adapter (if the v1 / v2 / v3 backu
- CIFS:
- CIFS mount is not a problem on Linux.
- It should be noted that cifs-utils is installed
- The path under CIFS must always begin without "/" (eg: "Sharename/Path")
- The path should look like this (eg: "/Sharename/Path")
- Optionally, you can enable / disable whether the backups should be deleted from the NAS
- NFS:
- NFS mount is not a problem on Linux.
- It should be noted that nfs-common is installed
- The path specification under NFS must always start without "/" (Ex: "Share name / path specification")
- The path should look like this (Ex: "/Sharename/path")
- Optionally, you can enable / disable whether the backups should be deleted from the NAS
- FTP:
- FTP is possible on all OS and serves as an alternative to the CIFS mount
Expand Down Expand Up @@ -193,8 +193,4 @@ Here is a list of problems encountered so far and their solutions, if any.
- Message = "No connection to states 127.0.0.0:6379[redis"
- sudo apt-get install redis-server

2. If the CIFS mount with IP address is not possible, the host name of the NAS should be used

3. No FTP Connect possible: check the notation of the path specification (eg: "/pathspecification/minimal")

4. No CIFS mount possible: Check the notation of the path specification (eg: "name/path")
2. If the CIFS mount with IP address is not possible, the host name of the NAS should be used
16 changes: 14 additions & 2 deletions io-package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
{
"common": {
"name": "backitup",
"version": "0.3.5",
"version": "0.3.6",
"news": {
"0.3.6": {
"en": "Fix Dropbox Backup, Fix Restore path for own Dir, Fix FTP and NAS path, Fix Access Token for dropbox",
"de": "Fix Dropbox Backup, Fix Restore-Pfad für Unterverzeichnisse, Fix FTP und NAS Pfad, Fix Access Token für Dropbox",
"ru": "Исправить резервное копирование Dropbox, исправить путь восстановления для собственного Dir, исправить FTP и путь NAS, исправить токен доступа для Dropbox",
"pt": "Corrija o Backup do Dropbox, corrija o caminho de restauração para o próprio Dir, corrija o caminho do FTP e do NAS, corrija o token de acesso para o dropbox",
"nl": "Fix Dropbox Backup, Fix Restore pad voor eigen Dir, Fix FTP en NAS pad, Fix Access Token voor dropbox",
"fr": "Réparer la sauvegarde Dropbox, Fixer le chemin de restauration pour son propre répertoire, Fixer le chemin FTP et NAS, Fixer le jeton d'accès pour la liste déroulante",
"it": "Correggi il backup di Dropbox, il percorso di ripristino fisso per il proprio percorso Dir, il percorso FTP e NAS corretto, il token di accesso fisso per il dropbox",
"es": "Repare Dropbox Backup, arregle la ruta de restauración para su propia dirección, arregle FTP y NAS, arregle el token de acceso para dropbox",
"pl": "Napraw Dropbox Backup, napraw ścieżkę Restore dla własnych Dir, napraw FTP i NAS ścieżkę, popraw token dostępu dla dropbox"
},
"0.3.5": {
"en": "Fix Translation, Fix Filename Suffix for Restore, Bugfix Title for Backup deletion",
"de": "Fix Übersetzungen, Fix Namens-Suffix für Restore, Bugfix Titel für Backups löschen",
Expand Down Expand Up @@ -378,7 +389,8 @@
"debugLevel": false,
"historyEntriesNumber": 25,

"restoreSource": "Local"
"restoreSource": "Local",
"restoreType": "Minimal"
},
"instanceObjects": [
{
Expand Down
35 changes: 30 additions & 5 deletions lib/list/cifs.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,15 @@ function nasList(options, types, log, callback) {
let dir = backupDir.replace(/\\/g, '/');

if (options.mountType === 'Copy') {
dir = options.dir.replace(/\\/g, '/');

if (options.ownDir === true && options.bkpType === 'Minimal') {
dir = options.dirMinimal.replace(/\\/g, '/');
} else
if (options.ownDir === true && options.bkpType === 'Total') {
dir = options.dirTotal.replace(/\\/g, '/');
} else
if (options.ownDir === false) {
dir = options.dir.replace(/\\/g, '/');
}
if (dir[0] !== '/' && !dir.match(/\w:/)) {
dir = '/' + (dir || '');
}
Expand Down Expand Up @@ -105,13 +112,27 @@ function getFile(options, fileName, toStoreName, log, callback) {
}

function mount(options, log, callback) {

let dir = options.dir;

if (options.ownDir === true && options.bkpType === 'Minimal') {
dir = options.dirMinimal;
} else
if (options.ownDir === true && options.bkpType === 'Total') {
dir = options.dirTotal;
}

if (options.mountType === 'CIFS') {
if (!options.mount.startsWith('//')) {
options.mount = '//' + options.mount;
}
child_process.exec(`mount -t cifs -o ${options.user ? 'user=' + options.user + ',password=' + options.pass : ''},rw,file_mode=0777,dir_mode=0777,vers=1.0 ${options.mount}/${options.dir} ${backupDir}`, (error, stdout, stderr) => {

if (!dir.startsWith('/')) {
dir = '/' + dir;
}
child_process.exec(`mount -t cifs -o ${options.user ? 'user=' + options.user + ',password=' + options.pass : ''},rw,file_mode=0777,dir_mode=0777,vers=1.0 ${options.mount}${dir} ${backupDir}`, (error, stdout, stderr) => {
if (error) {
child_process.exec(`mount -t cifs -o ${options.user ? 'user=' + options.user + ',password=' + options.pass : ''},rw,file_mode=0777,dir_mode=0777 ${options.mount}/${options.dir} ${backupDir}`, (error, stdout, stderr) => {
child_process.exec(`mount -t cifs -o ${options.user ? 'user=' + options.user + ',password=' + options.pass : ''},rw,file_mode=0777,dir_mode=0777 ${options.mount}${dir} ${backupDir}`, (error, stdout, stderr) => {
if (error) {
callback(error);
} else {
Expand All @@ -126,7 +147,11 @@ function mount(options, log, callback) {
});
} else
if (options.mountType === 'NFS') {
child_process.exec(`mount ${options.mount}:/${options.dir} ${backupDir}`, (error, stdout, stderr) => {
if (!dir.startsWith('/')) {
dir = '/' + dir;
}

child_process.exec(`mount ${options.mount}:${dir} ${backupDir}`, (error, stdout, stderr) => {
if (error) {
callback(error);
} else {
Expand Down
14 changes: 14 additions & 0 deletions lib/list/dropbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ function list(options, types, log, callback) {

let dir = (options.dir || '').replace(/\\/g, '/');

if (options.ownDir === true && options.bkpType === 'Minimal') {
dir = (options.dirMinimal || '').replace(/\\/g, '/');
} else
if (options.ownDir === true && options.bkpType === 'Total') {
dir = (options.dirTotal || '').replace(/\\/g, '/');
}

if (!dir || dir[0] !== '/') {
dir = '/' + (dir || '');
}
Expand Down Expand Up @@ -55,6 +62,13 @@ function getFile(options, fileName, toStoreName, log, callback) {

let dir = (options.dir || '').replace(/\\/g, '/');

if (options.ownDir === true && options.bkpType === 'Minimal') {
dir = (options.dirMinimal || '').replace(/\\/g, '/');
} else
if (options.ownDir === true && options.bkpType === 'Total') {
dir = (options.dirTotal || '').replace(/\\/g, '/');
}

if (!dir || dir[0] !== '/') {
dir = '/' + (dir || '');
}
Expand Down
18 changes: 18 additions & 0 deletions lib/list/ftp.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,20 @@ const fs = require('fs');
function list(options, types, log, callback) {
if (options.host && options.source === 'FTP') {
const client = new Client();

let dir = (options.dir || '').replace(/\\/g, '/');

if (options.ownDir === true && options.bkpType === 'Minimal') {
dir = (options.dirMinimal || '').replace(/\\/g, '/');
} else
if (options.ownDir === true && options.bkpType === 'Total') {
dir = (options.dirTotal || '').replace(/\\/g, '/');
}

if (!dir || dir[0] !== '/') {
dir = '/' + (dir || '');
}

client.on('ready', () => {
log.debug('FTP connected.');
client.list(dir, (err, result) => {
Expand Down Expand Up @@ -59,6 +69,14 @@ function getFile(options, fileName, toStoreName, log, callback) {
// copy file to options.backupDir
const client = new Client();
let dir = (options.dir || '').replace(/\\/g, '/');

if (options.ownDir === true && options.bkpType === 'Minimal') {
dir = (options.dirMinimal || '').replace(/\\/g, '/');
} else
if (options.ownDir === true && options.bkpType === 'Total') {
dir = (options.dirTotal || '').replace(/\\/g, '/');
}

if (!dir || dir[0] !== '/') {
dir = '/' + (dir || '');
}
Expand Down
9 changes: 6 additions & 3 deletions lib/scripts/01-mount.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@ function command(options, log, callback) {
if (options.mountType === 'CIFS' && options.mount && !options.mount.startsWith('//')) {
options.mount = '//' + options.mount;
}
if (options.mountType === 'CIFS' && options.mount && !options.dir.startsWith('/') || options.mountType === 'NFS' && options.mount && !options.dir.startsWith('/')) {
options.dir = '/' + options.dir;
}

if (!options.mount) {
return callback('NO mount path specified!');
}
if (options.mountType === 'CIFS') {
child_process.exec(`mount -t cifs -o ${options.user ? 'user=' + options.user + ',password=' + options.pass : ''},rw,file_mode=0777,dir_mode=0777,vers=1.0 ${options.mount}/${options.dir} ${options.backupDir}`, (error, stdout, stderr) => {
child_process.exec(`mount -t cifs -o ${options.user ? 'user=' + options.user + ',password=' + options.pass : ''},rw,file_mode=0777,dir_mode=0777,vers=1.0 ${options.mount}${options.dir} ${options.backupDir}`, (error, stdout, stderr) => {
if (error) {
child_process.exec(`mount -t cifs -o ${options.user ? 'user=' + options.user + ',password=' + options.pass : ''},rw,file_mode=0777,dir_mode=0777 ${options.mount}/${options.dir} ${options.backupDir}`, (error, stdout, stderr) => {
child_process.exec(`mount -t cifs -o ${options.user ? 'user=' + options.user + ',password=' + options.pass : ''},rw,file_mode=0777,dir_mode=0777 ${options.mount}${options.dir} ${options.backupDir}`, (error, stdout, stderr) => {
if (error) {
log.error(`[${options.name} ${stderr}`);
callback(error);
Expand All @@ -28,7 +31,7 @@ function command(options, log, callback) {
});
}
if (options.mountType === 'NFS') {
child_process.exec(`mount ${options.mount}:/${options.dir} ${options.backupDir}`, (error, stdout, stderr) => {
child_process.exec(`mount ${options.mount}:${options.dir} ${options.backupDir}`, (error, stdout, stderr) => {
if (error) {
log.error(`[${options.name} ${stderr}`);
callback(error);
Expand Down
File renamed without changes.
6 changes: 5 additions & 1 deletion lib/scripts/50-ftp.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,11 @@ function cleanFiles(client, dir, names, num, log, errors, callback) {
function command(options, log, callback) {
if (options.host && options.context && options.context.fileNames && options.context.fileNames.length) {
const client = new Client();
const fileNames = JSON.parse(JSON.stringify(options.context.fileNames));
const fileNames = JSON.parse(JSON.stringify(options.context.fileNames));

if (!options.dir.startsWith('/')) {
options.dir = '/' + options.dir;
}

let dir = (options.dir || '').replace(/\\/g, '/');

Expand Down
Loading

0 comments on commit 3d7b37b

Please sign in to comment.