Wie GitLab beim Sichern großer NextCloud-Stores hilft

Hallo Habr!



Heute möchte ich unsere Erfahrungen bei der Automatisierung von Big-Data-Backups von Nextcloud-Speichern in verschiedenen Konfigurationen teilen. Ich arbeite als Tankstelle in Lightning AK, wo wir uns mit dem Konfigurationsmanagement von IT-Systemen befassen. Nextcloud wird zur Datenspeicherung verwendet. Einschließlich mit einer verteilten Struktur mit Redundanz.



Die Probleme, die sich aus den Besonderheiten von Installationen ergeben, bestehen darin, dass viele Daten vorhanden sind. Die von Nextcloud bereitgestellte Versionierung, Redundanz, subjektive Gründe und mehr erzeugt viele Duplikate.



Hintergrund



Bei der Verwaltung von Nextcloud besteht ein akutes Problem bei der Organisation einer effektiven Sicherung, die verschlüsselt werden muss, da die Daten wertvoll sind.



Wir bieten Optionen zum Speichern eines Backups auf unserem eigenen Computer oder auf den von Nextcloud getrennten Computern eines Kunden, was einen flexiblen automatisierten Verwaltungsansatz erfordert.



Es gibt viele Clients, alle mit unterschiedlichen Konfigurationen und alle auf ihren Websites und mit ihren eigenen Eigenschaften. Hier passt die Standardmethode, wenn die gesamte Site Ihnen gehört und Backups von der Krone erstellt werden, schlecht.



Schauen wir uns zunächst die Eingabedaten an. Wir brauchen:



  • . minio.
  • .
  • / .
  • .
  • — .
  • : (), — .
  • .




GitLab. .



, , .



opensource, . , . , GitHub Nextcloud, , .





.



tar + gzip — . , .

— . minio . minio – , , -. .



( ) Borg Restic. , .





Borg Restic , . , , — CI/CD – GitLab.



: Nextcloud gitlab-runner. , Borg Restic.



? , , .



GitHub , Nextcloud, . , ( ) .gitlab-ci.yml



API CI/CD, . , 1d.



GitLab , , .



-.



:



  • , .
  • :
  • return code.
  • . , .
  • timeout. .
  • . .
  • .
  • , :
  • . .
  • , , stdout, . CI .
  • .


GitLab, , . bash.



— welcome.





. job CI/CD. , , , . S3.



— AWS ( ). minio . , .



ssh . , S3 ssh .



— S3, .

.



Borg none, . , , , .



. , . .







  • prepare
  • testcheck
  • maincommand
  • forcepostscript . .


Service functions



  • cleanup .
  • checklog .
  • ret exit handler.
  • checktimeout .


Environment



  • VERBOSE=1 (stdout).
  • SAVELOGSONSUCCES=1 .
  • INIT_REPO_IF_NOT_EXIST=1 , . - .
  • TIMEOUT . You can set it as 'm', 'h' or 'd' at the end.


. -:



  • KEEP_DAILY=7
  • KEEP_WEEKLY=4
  • KEEP_MONTHLY=6




  • ERROR_STRING — string for the check in log for error.
  • EXTRACT_ERROR_STRING — expression for show string if error.
  • KILL_TIMEOUT_SIGNAL — signal for killing if timeout.
  • TAIL — how many strings with errors on screen.
  • COLORMSG — color of mesage (default yellow).


, wordpress , , mysql. Nexcloud, . , , , .



Restic vs Borg



Borg Restic , , . , . .



, (, .):



  • . kill -9.
  • .
  • (, ).
  • .
  • S3.
  • .


1,6.

.



Borg S3, fuse , goofys. Restic S3 .



Goofys , , . beta, , , (). , , , .



, — .



.



  • Kill -9 .
  • . Borg .


Backuper
Borg 562Gb
Restic 628Gb


  • CPU

    borg , , goofys. 1,2 .
  • . Restic 0,5, Borg 200. . .
  • .


Backuper
Borg 500
Restic 5


  • S3 Restic . Borg goofys , , umount . S3 , , .
  • , .

    Restic – 3,5 .

    Borg, 100 SSD – 5 . .

    Borg S3 33 . .


Borg — GET/PUT S3. . — . ( ) restic , .



.



borg.





Borg’ — zstd. gzip, . lz4.



MySQL lz4 . , , Nextcloud .



Borg — , , .

-C auto,zstd

zstd

-

560Gb 562Gb . , , 628Gb. 2 , - auto,zstd.





, . , .



goofys --cache "--free:5%:/mnt/cache" -o allow_other --endpoint https://storage.yandexcloud.net --file-mode=0666 --dir-mode=0777 xxxxxxx.com /mnt/goofys
export BORG_PASSCOMMAND="cat /home/borg/.borg-passphrase"
borg list /mnt/goofys/borg1/
borg check --debug -p --verify-data /mnt/goofys/borg1/


(). Nextcloud . , .



.

API GitLab , , .





, , . tar.gz Bacula.




All Articles