Skip to content

Commit

Permalink
Merge pull request 'feature/fix-woodstock-v1' (#9) from feature/fix-w…
Browse files Browse the repository at this point in the history
  • Loading branch information
phoenix741 committed Sep 19, 2020
2 parents 7f2d856 + a0746a3 commit 85e96ae
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 3 deletions.
27 changes: 26 additions & 1 deletion server/src/backups/backups.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { InjectQueue, OnGlobalQueueProgress, Processor } from '@nestjs/bull';
import { JobId, Queue } from 'bull';
import { promises as fs } from 'fs';
import { Command, Console, createSpinner } from 'nestjs-console';
import { Command as Cmd } from 'commander';
import * as ora from 'ora';
import { join } from 'path';

Expand Down Expand Up @@ -88,20 +89,44 @@ export class BackupsCommand {
command: 'backuppc <path>',
description:
'Import backup from backuppc fuse directory. The fuse driver will present file in a flat view with a link for each backup that target the real backup. (See https://sourceforge.net/p/backuppc/mailman/message/35899426/)',
options: [
{
flags: '-h, --host <host>',
required: false,
description: 'Host to select for the backup (to limit the backup)',
},
{
flags: '-s, --start-date <date>',
required: false,
description: 'The minimum date to take to import of backup',
fn: parseInt,
},
{
flags: '-e, --end-date <date>',
required: false,
description: 'The maximum date to take to import of backup',
fn: parseInt,
},
],
})
async importFromBackuppc(path: string): Promise<void> {
async importFromBackuppc(path: string, cmd: Cmd): Promise<void> {
const { host, startDate, endDate } = cmd.opts();
const hosts = await this.hostsService.getHosts();
const originalBackup: Record<string, BackupPCSlot[]> = {};
const files = await fs.readdir(path);
for (const file of files) {
if (!hosts.includes(file)) continue;
if (!!host && file !== host) continue;

const backups: BackupPCSlot[] = [];

const backupDirEnts = await fs.readdir(join(path, file), { withFileTypes: true });
for (const dirEntry of backupDirEnts) {
if (DATEISO8601.test(dirEntry.name)) {
const date = Date.parse(dirEntry.name);
if (startDate && date < startDate) continue;
if (endDate && date > endDate) continue;

let name = dirEntry.name;
if (dirEntry.isSymbolicLink()) {
name = await fs.readlink(join(path, file, dirEntry.name));
Expand Down
3 changes: 2 additions & 1 deletion server/src/stats/stats.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export class StatsCommand {
{
flags: '-n, --number <number>',
description: 'Backup number',
fn: parseInt,
},
],
})
Expand All @@ -34,7 +35,7 @@ export class StatsCommand {
this.spinner = createSpinner();
this.spinner.start(`[Stats] ${host}/${number || 'NA'}: Progress 0%`);

let job = await this.hostsQueue.add('stats', { host, number: parseInt(number) }, { removeOnComplete: true });
let job = await this.hostsQueue.add('stats', { host, number }, { removeOnComplete: true });
this.jobId = job.id;
await job.finished();
job = (await this.hostsQueue.getJob(job.id)) || job;
Expand Down
2 changes: 1 addition & 1 deletion website/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#
# -------- Build --------
FROM node:12-alpine as build
FROM node:14-alpine as build
LABEL MAINTAINER="Ulrich Van Den Hekke <ulrich.vdh@shadoware.org>"

WORKDIR /src
Expand Down
9 changes: 9 additions & 0 deletions website/doc/addnewhost.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,12 @@ After the creation of the file with the configuration we need to add it to the f
- server-ovh-2
- server-ovh-3
```

## Check you can connect to the host without password.

Using the same user of `Woodstock Backup`, try to connect to the host with the command:

```bash
ssh-copy-id root@host
ssh root@host
```

0 comments on commit 85e96ae

Please sign in to comment.