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

[feature] Import the backup file into the "import" function in WebUI #130

Open
Tziware opened this issue Jul 13, 2021 · 16 comments
Open

[feature] Import the backup file into the "import" function in WebUI #130

Tziware opened this issue Jul 13, 2021 · 16 comments

Comments

@Tziware
Copy link

Tziware commented Jul 13, 2021

Would be great to be able to restore a backup within the webUI.
Even if its just the websites and snapshot history.

@dgtlmoon
Copy link
Owner

@Tziware

Even if its just the websites and snapshot history.

isnt that sort of the whole thing? isnt that what the program does? :) or i dont understand?

@dgtlmoon dgtlmoon changed the title Backup/Restore function in WebUI [feature] Backup/Restore function in WebUI Jul 13, 2021
@Tziware
Copy link
Author

Tziware commented Jul 13, 2021

Recently I was moving between servers so installed a second instance on another server used the backup function in the instance on my existing server thinking thats what it was for
I was surprised that the restore function didnt use the file generated by the backup function.

@g000m
Copy link

g000m commented Jul 14, 2021

+1

@dgtlmoon dgtlmoon changed the title [feature] Backup/Restore function in WebUI [feature] Import the backup file into the "import" function in WebUI Jul 23, 2021
@dgtlmoon
Copy link
Owner

You can always do this with the docker volume copy for now, but fair idea yes

@bayview
Copy link

bayview commented Aug 10, 2021

In the meantime, can we get effective instructions on how to manually restore a backup? I tried the one in the Wiki with no success...

After exporting an accurate BACKUP_PATH, I get this:

$ docker run -v datastore-volume:/datastore -v $BACKUP_PATH:/backup.zip python:3.8-slim bash -c "apt-get update && apt-get install unzip -y; unzip -o /backup.zip-d /datastore"
Unable to find image 'python:3.8-slim' locally
3.8-slim: Pulling from library/python
33847f680f63: Pull complete
e8124950597e: Pull complete
cc636c24d49d: Pull complete
1fbf3ac5d4b6: Pull complete
37cfb6b6e136: Pull complete
Digest: sha256:2a41e35b42bf984f05b4c40bd444d0ea3224e6cdd1b7a683ee364521f5501de3
Status: Downloaded newer image for python:3.8-slim
Get:1 http://security.debian.org/debian-security buster/updates InRelease [65.4 kB]
Get:2 http://deb.debian.org/debian buster InRelease [122 kB]
Get:3 http://deb.debian.org/debian buster-updates InRelease [51.9 kB]
Get:4 http://security.debian.org/debian-security buster/updates/main amd64 Packages [299 kB]
Get:5 http://deb.debian.org/debian buster/main amd64 Packages [7907 kB]
Get:6 http://deb.debian.org/debian buster-updates/main amd64 Packages [15.2 kB]
Fetched 8460 kB in 9s (976 kB/s)
Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
Suggested packages:
zip
The following NEW packages will be installed:
unzip
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 172 kB of archives.
After this operation, 580 kB of additional disk space will be used.
Get:1 http://deb.debian.org/debian buster/main amd64 unzip amd64 6.0-23+deb10u2 [172 kB]
debconf: delaying package configuration, since apt-utils is not installed
Fetched 172 kB in 1s (245 kB/s)
Selecting previously unselected package unzip.
(Reading database ... 6840 files and directories currently installed.)
Preparing to unpack .../unzip_6.0-23+deb10u2_amd64.deb ...
Unpacking unzip (6.0-23+deb10u2) ...
Setting up unzip (6.0-23+deb10u2) ...
unzip: cannot find or open /backup.zip-d, /backup.zip-d.zip or /backup.zip-d.ZIP.


The issue is probably something quite simple, but I have never used docker.

@bayview
Copy link

bayview commented Aug 10, 2021

I solved my problem with the restore instructions from the wiki.

The command line in the wiki is missing a space before the last "-d /datastore"

The correct command is:
docker run -v datastore-volume:/datastore -v $BACKUP_PATH:/backup.zip python:3.8-slim bash -c "apt-get update && apt-get install unzip -y; unzip -o /backup.zip -d /datastore"

Two recommendations:

  1. Mention on the home page that installing a new version will wipe out all the data and settings.
  2. Put the backup and restore instructions on the home page.

Thanks for a very useful tool!

@dgtlmoon
Copy link
Owner

@bayview thanks I fixed that wiki!

1 - It will never wipe out your data just because of a upgrade, it must be because of something else, maybe you didnt kill the docker process before you ran your unzip.. that would confuse the system

2 - yes!

@niemsoen
Copy link

niemsoen commented Aug 9, 2023

Is there also a way to backup the settings,snapshots,etc... without the docker image running?
Mine doesn't start anymore because of this bug. (output taken with sudo docker logs CONTAINER_ID)

Process Process-1:
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/multiprocessing/process.py", line 314, in _bootstrap
    self.run()
  File "/usr/local/lib/python3.10/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/app/changedetectionio/changedetection.py", line 96, in main
    datastore = store.ChangeDetectionStore(datastore_path=app_config['datastore_path'], version_tag=__version__)
  File "/app/changedetectionio/store.py", line 56, in __init__
    from_disk = json.load(json_file)
  File "/usr/local/lib/python3.10/json/__init__.py", line 293, in load
    return loads(fp.read(),
  File "/usr/local/lib/python3.10/codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte

This bug is probably not reproducible, because my system had a crash, so this is literally all the info I have.

I'd highly appreciate, if you could point out a way to backup the instance offline so that I can import it again in a new instance with the instructions from the wiki. Thanks in advance! 💯

@ghost
Copy link

ghost commented Aug 24, 2023

a pull request was opened by the developer at the end of 2022: #1248

@ghost
Copy link

ghost commented Aug 24, 2023

On a related note, does the Python package make backing up changedetection.io config data easier? As a beginner I may switch (see this discussion about auto-starting the pip version).

@c0d3z3r0
Copy link

c0d3z3r0 commented Apr 23, 2024

I solved my problem with the restore instructions from the wiki.

The command line in the wiki is missing a space before the last "-d /datastore"

The correct command is: docker run -v datastore-volume:/datastore -v $BACKUP_PATH:/backup.zip python:3.8-slim bash -c "apt-get update && apt-get install unzip -y; unzip -o /backup.zip -d /datastore"

Shorter and faster:

docker run -ti --rm -v $PWD/backup.zip:/backup.zip -v changedetectioniogit_changedetection-data:/datastore alpine sh -c "rm -r /datastore/*; unzip -d /datastore /backup.zip"

@morenone
Copy link

I tried all the above steps to no avail. Then I changed the permissions inside the datastore folder to 777 and everything worked.

@Lifes-A-Glitch
Copy link

Even trying everything listed above and in the wiki, it doesn't restore for me. Even changing the permissions in the datastore folder didn't work.

@stdestro
Copy link

stdestro commented Nov 19, 2024

HI, did the same. new install on a new machine. tried changing datastore folder permissions to 777 with no success.
I cannot restore from a previous backup.
this are the commands i ran on my machine, btw i'm not getting any error

sudo docker kill changedetection.io

export BACKUP_PATH=/home/ubuntu/backup1.zip

sudo docker run -d --restart always -p "127.0.0.1:5000:5000" -v datastore-volume:/datastore --name changedetection.io dgtlmoon/changedetection.io

sudo docker restart changedetection.io

@stdestro
Copy link

So, I noticed there were two volumes in Portainer. Changed mount point to the "unused" volume and now it works

Screenshot 2024-11-19 at 12 41 56

@Rundervinkje
Copy link

This thread helped me out a lot. But let me add my experiences/noob-learning moments for future noobs finding this difficult.

(i am using a Pi over SSH + portainer)
Learning point 1: you can place the backup file anywhere on your device as long as you know the path. No need to dive into the volume of the container. Use 'pwd' in console to find the [path] you placed it, add the [file name], add the [.zip]. Thats the path you have to use in the workinstuction.
Learning point 2: the code in the workinstruction from https://github.com/dgtlmoon/changedetection.io/wiki/Restoring-backup-files can just be run from your terminal via ssh. There is no need to go into the portainer console window to do this.
Learning point 3: As Stdestro mentioned in the post above, there is now a second volume that can be seen in Portainer -> volumes (in my case it was named similar to the orginal changedetection volume, plus an added "io" halfway.
To ensure changedetection uses the NEW (old backup) version.

  • Go into portainer webUI,
  • stop the container (in my case also the playwright container).
  • open the changedetection container
  • in the top bar 'Action', go to 'duplicate/edit'
  • Scroll down to 'Advanced container settings' -> 'Volumes'
  • from the drop-down, select the NEW (old backup) version.
  • Restart both containers.

Hopes this helps
#keep-on-learning!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants