Skip to content

Commit a30114a

Browse files
committed
disabling remote instance by default
1 parent e380e0e commit a30114a

File tree

7 files changed

+200
-59
lines changed

7 files changed

+200
-59
lines changed

README.md

Lines changed: 56 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,31 @@
11
# Backup
22

3-
This App allows admin to create backup images of their Nextcloud
3+
This App allows admin to create and store backup images of their Nextcloud
44

5+
## Restoring Points
56

7+
A restoring point is an image of your Nextcloud at a specific time. A restoring point can be:
68

7-
## Restoring Points
9+
- '**Complete**' (or Full) and contains a backup of :
10+
* the instance of Nextcloud (core),
11+
* the apps of the Nextcloud (from `apps/` and `custom_apps/`),
12+
* A dump of the database,
13+
* the data of the Nextcloud including users' files.
814

9-
A restoring point is an image of your Nextcloud at a specific time.
10-
A restoring point can be:
11-
- a '**full**' backup that contains all data that are managed by the App,
12-
- an '**incremental**' backup that only contains modified files since your last 'full' backup.
15+
- '**Partial**' (or Incremental) that contains a backup of :
16+
* the instance of Nextcloud,
17+
* the apps of the Nextcloud,
18+
* A dump of the database,
19+
* data that have been generated or edited since the last **Complete Backup**
1320

1421
### What data are available in a Restoring Point
1522

16-
Please note that the Backup App will not store ALL data from your Nextcloud. As an example, remote files does not have backup.
23+
Please note that the Backup App will not store ALL data from your Nextcloud. As an example, remote files
24+
does not have backup.
1725
This is a quick list of what can be restored and what cannot be restored when using the Backup App:
1826

1927
A restoring point will store
28+
2029
- your current Nextcloud,
2130
- the `apps/` folder,
2231
- your local data, defined by `'datadirectory'` in `config/config.php`,
@@ -25,14 +34,28 @@ A restoring point will store
2534
- A full dump of your database.
2635

2736
A restoring point will **NOT** store:
37+
2838
- Remote data, even if the filesystem is available locally.
2939

30-
A Restoring Point also contains a file named `metadata.json` that contains information like:
40+
A Restoring Point also contains a file named `restoring-point.data` that contains metadata about the
41+
backup:
42+
3143
- Version of your Nextcloud
32-
- The ID of the full backup in case of incremental backups,
44+
- The ID of the parent backup in case of partial backup,
3345
- The list of compressed file that contains the backup files,
3446
- Checksum for those files,
35-
- the date of the restoring point.
47+
- the date of the restoring point,
48+
- information related to the health of the files
49+
50+
_Note: the file `restoring-point.data` can confirm the integrity of all files and parts of the backup. If
51+
the file is lost, it is still possible to restore a restoring point.
52+
The normal process is to re-create the `restoring-point.data` a new one, however :
53+
54+
- there is no way to confirm the integrity of content of the backup,
55+
- the restoring process will require some knowledge from the admin about the infrastructure from the
56+
original instance that generated the backup.
57+
58+
3659

3760
## Quick documentation:
3861

@@ -52,36 +75,31 @@ You can upload your backup files on a remote instance
5275

5376
./occ backup:remote:remove cloud.example.net
5477

55-
56-
**Note**: if you enable the backup on remote instance, it is strongly advice to [keep your current setup somewhere](), or
57-
your files won't be available without your identity nor readable without your encryption key
58-
78+
**Note**: if you enable the backup on remote instance, it is strongly advice
79+
to [keep your current setup somewhere](), or your files won't be available without your identity nor
80+
readable without your encryption key
5981

6082
### Manage your restoring point
6183

62-
6384
**Create a new Restoring Point**
6485

6586
./occ backup:point:create [--incremental]
6687

6788
The `--incremental` option will create an incremental backup
6889

69-
7090
**Upload a Restoring Point**
7191

7292
./occ backup:point:upload <pointId>
7393

74-
This will request all configured remote instances to check the sanity of any previous upload for this Restoring
75-
Point, and will only upload missing/faulty file.
76-
94+
This will request all configured remote instances to check the sanity of any previous upload for this
95+
Restoring Point, and will only upload missing/faulty file.
7796

7897
**List restoring points**
7998

8099
./occ backup:point:list
81100

82101
You can search and compare restoring point available locally and on configured remote instance.
83102

84-
85103
**Search for a specific file:**
86104

87105
./occ backup:file:search [--since|--until|--point] <string>
@@ -90,7 +108,6 @@ Search for a file, based on its name.
90108

91109
example: `./occ backup:file:search test.jpg --since 2021-09-23`
92110

93-
94111
**History of specific a file:**
95112

96113
./occ backup:file:history [--since|--until] <dataPack> <fullPath>
@@ -99,59 +116,55 @@ Display the history of a file.
99116

100117
example: `./occ backup:file:history data cult/files/backup1.md`
101118

102-
103119
**Import a Restoring Point**
104120

105-
If you start using the app, you will face at one point a situation where an important Restoring Point is available somewhere but cannot be find in your database.
106-
As an example, when restoring a Backup, all Restoring Point created after this backup won't be in database anymore. This is normal as restoring the backup fully overwrite your database.
107-
In that case, you can run this command:
121+
If you start using the app, you will face at one point a situation where an important Restoring Point is
122+
available somewhere but cannot be find in your database. As an example, when restoring a Backup, all
123+
Restoring Point created after this backup won't be in database anymore. This is normal as restoring the
124+
backup fully overwrite your database. In that case, you can run this command:
108125

109126
./occ backup:point:scan <pointId>
110127

111-
If it cannot be found, you will need to manually copy the folder that contains the Restoring Point in the appdata folder: data/appdata_qwerty123/backup/
112-
128+
If it cannot be found, you will need to manually copy the folder that contains the Restoring Point in the
129+
appdata folder: data/appdata_qwerty123/backup/
113130

114131
**Verify integrity of a Restoring Point**
115132

116133
./occ backup:point:details <pointId>
117134

118-
119-
120135
## Restoration
121136

122137
You can restore a single file or the whole instance to a previous state:
123138

124139
./occ backup:point:restore <pointId> [--file <filename>] [--data <dataPack>] [--chunk chunkName]
125140

126-
Please note that you can go back to a previous backup of your instance from any Nextcloud compatible with the Backup App.
127-
There is no need to install the exact same version as it will be reverted to the one used when creating the Restoring Point.
128-
Meaning that you can fully restore your instance of Nextcloud even if you lost your harddrive, as long as you kept a copy of
129-
the Restoring Point (upload to another remote instance)
130-
141+
Please note that you can go back to a previous backup of your instance from any Nextcloud compatible with
142+
the Backup App. There is no need to install the exact same version as it will be reverted to the one used
143+
when creating the Restoring Point. Meaning that you can fully restore your instance of Nextcloud even if
144+
you lost your harddrive, as long as you kept a copy of the Restoring Point (upload to another remote
145+
instance)
131146

132147
## Exporting configuration
133148

134-
This is an important step of your configuration of the Backup App
135-
Some information will be needed in case you start storing your backup on remote instances:
149+
This is an important step of your configuration of the Backup App Some information will be needed in case
150+
you start storing your backup on remote instances:
136151

137152
- The identity of your Nextcloud,
138153
- The encryption key used to encrypt your backup.
139154

140-
**While the identity can be changed and your access to the remote files can be restored by
141-
executing some command on the remote instance to update your new identity, a missing encryption
142-
key means that your remote backup cannot be decrypted and are totally useless.**
155+
**While the identity can be changed and your access to the remote files can be restored by executing some
156+
command on the remote instance to update your new identity, a missing encryption key means that your
157+
remote backup cannot be decrypted and are totally useless.**
143158

144159
**Please note that creating a new identity will disable the sanity check on the metadata file.**
145160

146161
./occ backup:setup:export [--key] > ~/backup_setup.json
147162

148-
Using the `--key` option will generate a Key, used to encrypt/decrypt the data of your setup.
149-
The key generated during the export of your setup needs to be stored somewhere safe!
163+
Using the `--key` option will generate a Key, used to encrypt/decrypt the data of your setup. The key
164+
generated during the export of your setup needs to be stored somewhere safe!
150165

151166
./occ backup:setup:import [--key <key>] < ~/backup_setup.json
152167

153-
154-
155168
### Known issues, missing features:
156169

157170
- files are not encrypted when uploading to a remote instance

lib/Command/RemoteAdd.php

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
use OCA\Backup\Exceptions\RemoteInstanceNotFoundException;
4747
use OCA\Backup\Exceptions\RemoteInstanceUidException;
4848
use OCA\Backup\Model\RemoteInstance;
49+
use OCA\Backup\Service\ConfigService;
4950
use OCA\Backup\Service\RemoteStreamService;
5051
use Symfony\Component\Console\Input\InputArgument;
5152
use Symfony\Component\Console\Input\InputInterface;
@@ -68,28 +69,38 @@ class RemoteAdd extends Base {
6869
/** @var RemoteStreamService */
6970
private $remoteStreamService;
7071

72+
/** @var ConfigService */
73+
private $configService;
74+
7175

7276
/**
7377
* RemoteAdd constructor.
7478
*
7579
* @param RemoteRequest $remoteRequest
7680
* @param RemoteStreamService $remoteStreamService
81+
* @param ConfigService $configService
7782
*/
7883
public function __construct(
7984
RemoteRequest $remoteRequest,
80-
RemoteStreamService $remoteStreamService
85+
RemoteStreamService $remoteStreamService,
86+
ConfigService $configService
8187
) {
82-
parent::__construct();
83-
8488
$this->remoteRequest = $remoteRequest;
8589
$this->remoteStreamService = $remoteStreamService;
90+
$this->configService = $configService;
91+
92+
parent::__construct();
8693
}
8794

8895

8996
/**
9097
*
9198
*/
9299
protected function configure() {
100+
if (!$this->configService->isRemoteEnabled()) {
101+
$this->setHidden(true);
102+
}
103+
93104
$this->setName('backup:remote:add')
94105
->setDescription('Add remote instances to store your backups')
95106
->addArgument('address', InputArgument::REQUIRED, 'address of the remote instance of Nextcloud');
@@ -110,6 +121,10 @@ protected function configure() {
110121
* @throws RemoteInstanceException
111122
*/
112123
protected function execute(InputInterface $input, OutputInterface $output): int {
124+
if (!$this->configService->isRemoteEnabled()) {
125+
throw new RemoteInstanceException('not enabled');
126+
}
127+
113128
$address = $input->getArgument('address');
114129
if (strtolower($address) === RemoteInstance::LOCAL || strtolower($address) === RemoteInstance::ALL) {
115130
throw new RemoteInstanceException($address . ' is a reserved name');
@@ -314,12 +329,18 @@ private function saveRemoteInstance(
314329
$output->writeln('');
315330
$output->writeln('<error>Important note</error>: ');
316331
$output->writeln('Uploaded backup are encrypted which is good, don\'t you think ?');
317-
$output->writeln('However, it also means that <options=bold>if you loose the Encryption Key, your backup will be totally useless</>');
332+
$output->writeln(
333+
'However, it also means that <options=bold>if you loose the Encryption Key, your backup will be totally useless</>'
334+
);
318335
$output->writeln('');
319336
$output->writeln('It is advised to export the setup of the Backup App in the file of your choice.');
320-
$output->writeln('Keep in mind that with this file, any installation of Nextcloud can access your backup,');
337+
$output->writeln(
338+
'Keep in mind that with this file, any installation of Nextcloud can access your backup,'
339+
);
321340
$output->writeln('restore them and access the data of your users');
322-
$output->writeln('While this is an option, ts is also advised to force the creation of a key to encrypt the content of the file:');
341+
$output->writeln(
342+
'While this is an option, ts is also advised to force the creation of a key to encrypt the content of the file:'
343+
);
323344
$output->writeln('');
324345
$output->writeln(' ./occ backup:setup:export [--key] > ~/backup_setup.json');
325346
$output->writeln('');

lib/Command/RemoteList.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@
3636
use ArtificialOwl\MySmallPhpTools\Exceptions\SignatureException;
3737
use OC\Core\Command\Base;
3838
use OCA\Backup\Db\RemoteRequest;
39+
use OCA\Backup\Exceptions\RemoteInstanceException;
3940
use OCA\Backup\Model\RemoteInstance;
41+
use OCA\Backup\Service\ConfigService;
4042
use OCA\Backup\Service\RemoteStreamService;
4143
use Symfony\Component\Console\Helper\Table;
4244
use Symfony\Component\Console\Input\InputInterface;
@@ -58,16 +60,25 @@ class RemoteList extends Base {
5860
/** @var RemoteStreamService */
5961
private $remoteStreamService;
6062

63+
/** @var ConfigService */
64+
private $configService;
65+
6166

6267
/**
6368
* RemoteList constructor.
6469
*
6570
* @param RemoteRequest $remoteRequest
6671
* @param RemoteStreamService $remoteStreamService
72+
* @param ConfigService $configService
6773
*/
68-
public function __construct(RemoteRequest $remoteRequest, RemoteStreamService $remoteStreamService) {
74+
public function __construct(
75+
RemoteRequest $remoteRequest,
76+
RemoteStreamService $remoteStreamService,
77+
ConfigService $configService
78+
) {
6979
$this->remoteRequest = $remoteRequest;
7080
$this->remoteStreamService = $remoteStreamService;
81+
$this->configService = $configService;
7182

7283
parent::__construct();
7384
}
@@ -77,6 +88,10 @@ public function __construct(RemoteRequest $remoteRequest, RemoteStreamService $r
7788
*
7889
*/
7990
protected function configure() {
91+
if (!$this->configService->isRemoteEnabled()) {
92+
$this->setHidden(true);
93+
}
94+
8095
$this->setName('backup:remote:list')
8196
->setDescription('Listing configured remote instances');
8297
}
@@ -87,8 +102,13 @@ protected function configure() {
87102
* @param OutputInterface $output
88103
*
89104
* @return int
105+
* @throws RemoteInstanceException
90106
*/
91107
protected function execute(InputInterface $input, OutputInterface $output): int {
108+
if (!$this->configService->isRemoteEnabled()) {
109+
throw new RemoteInstanceException('not enabled');
110+
}
111+
92112
$output = new ConsoleOutput();
93113
$output = $output->section();
94114
$table = new Table($output);

0 commit comments

Comments
 (0)