Datensicherung: Difference between revisions

From Dolibarr ERP CRM Wiki
Jump to navigation Jump to search
No edit summary
m (Updating interlang links (links to translated versions of this page in other languages) triggered by origin English page "Backups" update.)
 
(12 intermediate revisions by 5 users not shown)
Line 1: Line 1:
<!-- BEGIN interlang links -->
<!-- Do NOT edit this section
    Links below are automatically managed by PolyglotBot
    You can edit links on the English source page : Backups -->
[[en:Backups]]
[[fr:Sauvegardes]]
[[es:Copias_de_seguridad]]
[[zh:备份]]
<!-- END interlang links -->
Datensicherung = Backup  
Datensicherung = Backup  




[[Category:Admin de]]
[[Category:Admin de]]
{{TemplateDoKUser}}
{{TemplateDocAdminDE}}


= [[File:Who.png]] Warum? =
= [[File:Who.png]] Warum? =
Line 28: Line 38:


== Datenbank ==
== Datenbank ==
The database contains all data you have added from Dolibarr screens (except the attached/generated files that are presented in next chapter).
Die Datenbank beinhaltet alle Daten, die man im Dolibarr Programm eingegeben/erzeugt hat, also z.B. Partner, Kontakte, Produkte, Belege, Termine .. (außer angehängte oder durch Belege erzeugte Dokumente).<br>
Saving the database must be done in a global way (all content). It is advised to '''save the database regularly'''. See the chapter "How" later in this  document.
Die Sicherung der Datenbank muss gesamtheitlich erfolgen (alle Daten/Tabellen).<br>
Es wird empfohlen die '''Datenbank regelmäßig zu sichern'''.  


== Dokumente ==
== Dokumente ==
All documents related to your Dolibarr instance are saved into directory defined into your config file ''dolibarrdir/htdocs/conf/conf.php''. If you kept the choice by default during first installation, it should be something like ''dolibarrdir/documents''. This directory must be completely saved.  
Alle Dokumente, die sich auf Ihre Dolibarr-Instanz beziehen, werden in einem Verzeichnis gespeichert, das in Ihrer Konfigurationsdatei definiert ist. ''dolibarrdir/htdocs/conf/conf.php''. Wenn Sie die Auswahl bei der Erstinstallation standardmäßig beibehalten haben, sollte sie etwa so aussehen ''dolibarrdir/documents''. Dieses Verzeichnis muss vollständig gespeichert sein.  
When making an upgrade, the upgrade process should not change this directory, however this directory can be read and write by web server at any time, it might be altered by a bad action or a bug. To be sure to keep all your joined files and be able to restore them if they are accidentally deleted or altered, just make a copy of all content of this directory.
 
Bei einem Upgrade sollte der Upgrade-Prozess dieses Verzeichnis nicht ändern, aber dieses Verzeichnis kann vom Webserver jederzeit gelesen und geschrieben werden, es kann durch eine schlechte Aktion oder einen Fehler geändert werden. Um sicherzustellen, dass Sie alle Ihre verbundenen Dateien behalten und sie wiederherstellen können, wenn sie versehentlich gelöscht oder geändert werden, erstellen Sie einfach eine Kopie des gesamten Inhalts dieses Verzeichnisses.


''Note'': copying the whole folder containing all your documents might be an heavy process, so if you can't do this regularly, at least make a backup of your database (which should be a lot smaller and would still enable you to recover most of your data, which can then be used to regenerate most of your documents).
''Hinweis'': Das Kopieren des gesamten Ordners mit allen Ihren Dokumenten könnte ein ressourcenintensiver Prozess sein, also wenn Sie dies nicht regelmäßig tun können, machen Sie zumindest ein Backup Ihrer Datenbank (die viel kleiner sein sollte und es Ihnen trotzdem ermöglichen würde, die meisten Ihrer Daten wiederherzustellen, die dann verwendet werden können, um die meisten Ihrer Dokumente zu regenerieren).


== Code change ==
== Code Änderung ==


Finally, any custom development of modules, ie: all php files (or others) that would have been added or modified to accommodate specific needs, should also be saved. In most cases, you are not concerned by this point.
Schließlich sollte jede kundenspezifische Entwicklung von Modulen, d.h. alle php-Dateien (oder andere), die hinzugefügt oder geändert worden wären, um spezifischen Anforderungen gerecht zu werden, ebenfalls gespeichert werden. In den meisten Fällen sind Sie von diesem Punkt nicht betroffen.


= [[File:Who.png]] Wann ? =
= [[File:Who.png]] Wann ? =
Frequency of backups depends on how often you use Dolibarr and what you accept to loose if something happens. More often the frequency, less data will be lost in case of a crash/failure.
Die Häufigkeit der Backups hängt davon ab, wie oft Sie Dolibarr verwenden und welche Konsequenzen Sie akzeptieren, wenn etwas passiert. Je häufiger die Frequenz der Backups, desto weniger Daten gehen bei einem Crash/Ausfall verloren.


Also, you can choose to backup more often one part (like the database) that is more critical, and less regularly others because they are more heavy (like the documents).
Außerdem haben Sie die Wahl, ob Sie häufiger kritischere Teile (wie die Datenbank) sichern und weniger regelmäßig andere Teile, wie z.B. die Dokumente mit hohem Speicherbedarf.


As a good starting point, you database should be backed every 1 month or even every 1 week depending on your usage, while documents can be backed every 6 months or every 1 month depending on your usage once again.
Als guter Ausgangspunkt sollte Ihre Datenbank je nach Nutzung einmal im Monat oder sogar einmal die Woche gesichert werden, während die Dokumente alle 6 Monate oder einmal im Monat (je nach Nutzung) gesichert werden können.


Also, the conf.php file needs to be backed only once (since it only changes if you change your host, and anyway can be made manually).
Die <code>conf.php</code> Datei muss hingegen nur einmal gesichert werden (da sie sich nur ändert, wenn Sie Ihren Host wechseln, und trotzdem manuell erstellt werden kann).


= [[File:Who.png]] Wie ?=
= [[File:Who.png]] Wie ?=


== The configuration file ==
== Die Konfigurationsdatei ==
A simple copy of file ''conf/conf.php'' into a directory dedicated to your backup is enough.
Eine einfache Kopie der Datei <code>conf/conf.php</code> in einem Verzeichnis, das für ihr Backup bestimmt ist, genügt.


== The database ==
== Die Datenbank ==
There are 4 ways to backup your database:
Es gibt 4 Möglichkeiten, Ihre Datenbank zu sichern:


=== Using Dolibarr system backup tool ===
=== Verwendung des Dolibarr System-Backup-Tools ===


This is the simplest way to make your backup, and in addition all your backups will be stored on server and will be listed, so that you can retrieve any version anyday.
Dies ist der einfachste Weg, um Ihr Backup zu erstellen, und außerdem werden alle Ihre Backups auf dem Server gespeichert und aufgelistet, so dass Sie jede Version jederzeit abrufen können.


If you use a recent enough version of Dolibarr, just log into Dolibarr with an administrator account (only admins can use system tools).
Wenn Sie eine neuere Version von Dolibarr verwenden, melden Sie sich einfach mit einem Administratorkonto bei Dolibarr an (nur Administratoren können Systemtools verwenden).


Then go to '''Home -> System tools -> Backups'''.
Gehen Sie anschließend zu '''Home -> System tools -> Backups'''.
Choose your options for your backup (you can keep all default values).
Wählen Sie Ihre Backup Optionen (Sie können alle Standardwerte verwenden).


''Alternative'': the default method '''MySQL Dump (mysqldump)''' also needs that you have access to the mysqldump binary in execution on your server. If you are on a shared host that disable the mysqldump usage, you can try other method called '''MySQL Dump (php)'''. This method is not guaranted at 100%, so please try it first by yourself by making a backup and then restoring it on a local non production server to check that your data is correctly saved.
''Alternative'': Für die Standardmethode '''MySQL Dump (mysqldump)''' ist es notwendig, dass Sie ausführbaren Zugriff auf die mysqldump binary auf ihrem Server haben. Auf einem shared host mit disabled mysqldump usage, können Sie eine andere Method namens '''MySQL Dump (php)''' versuchen. Da bei dieser Methode nicht zu 100% gewährleistet ist, dass Ihre Daten korrekt gespeichert werden, stellen Sie das bitte selbst sicher, indem Sie ein Backup machen und dieses in einer lokalen nicht-produktiven Umgebung wiederherstellen.


=== Using mysqldump ===
=== Using mysqldump ===
If you prefer a manual mode, you can also use the backup tool designed for your database.
If you prefer a manual mode, you can also use the backup tool designed for your database.
With Mysql, the command to backup your database into a file is :
With Mysql, the command to backup your database into a file is :
<source lang="bash">
<syntaxHighlight lang="bash">
mysqldump -u user -pyourpass --result-file=mysqldump_databasename_version_date.sql databasename
mysqldump -u user -pyourpass --result-file=mysqldump_databasename_version_date.sql databasename
</source>
</syntaxHighlight>
where :
where :
* ''user'' is MySQL user that Dolibarr use to connect to database,
* ''user'' is MySQL user that Dolibarr use to connect to database,
Line 88: Line 100:


If you want to have your file compressed (compressé) :
If you want to have your file compressed (compressé) :
<source lang="bash">
<syntaxHighlight lang="bash">
mysqldump databasename -h host -u user -pyourpass -l --single-transaction -K --add-drop-table=TRUE --tables -c -e --hex-blob --default-character-set=utf8 | bzip2 > mysqldump_databasename_version_date.bz2
mysqldump databasename -h host -u user -pyourpass -l --single-transaction -K --add-drop-table=TRUE --tables -c -e --hex-blob --default-character-set=utf8 | bzip2 > mysqldump_databasename_version_date.bz2
</source>
</syntaxHighlight>
Dump file will be generated with a bzip compressed format.
Dump file will be generated with a bzip compressed format.


Line 96: Line 108:


With Linux, to make a regular backup at 1:30 each day into file mysqldump_databasename_DD.sql.bz2, you can add this into your cron file:
With Linux, to make a regular backup at 1:30 each day into file mysqldump_databasename_DD.sql.bz2, you can add this into your cron file:
<source lang="bash">
<syntaxHighlight lang="bash">
30 1 * * * mysqldump databasename -h host -u user -pyourpass -l --single-transaction -K --add-drop-table=TRUE --tables -c -e --hex-blob --default-character-set=utf8 | bzip2 > mysqldump_databasename_`date +%d`.sql.bz2
30 1 * * * mysqldump databasename -h host -u user -pyourpass -l --single-transaction -K --add-drop-table=TRUE --tables -c -e --hex-blob --default-character-set=utf8 | bzip2 > mysqldump_databasename_`date +%d`.sql.bz2
</source>
</syntaxHighlight>


=== Using phpMyAdmin ===
=== Using phpMyAdmin ===
Line 116: Line 128:
[[File:Warning.png]] in any case, '''your sql backup file should disable foreign keys prior to restoring''', else your backup won't be restorable because of foreign keys clashing!
[[File:Warning.png]] in any case, '''your sql backup file should disable foreign keys prior to restoring''', else your backup won't be restorable because of foreign keys clashing!
Eg: Add FOREIGN_KEY_CHECKS in headers and footers:
Eg: Add FOREIGN_KEY_CHECKS in headers and footers:
<source lang="sql">
<syntaxHighlight lang="sql">
-- SQL Dump
-- SQL Dump
-- Server version: 5.5.8
-- Server version: 5.5.8
Line 140: Line 152:


SET FOREIGN_KEY_CHECKS=1;
SET FOREIGN_KEY_CHECKS=1;
</source>
</syntaxHighlight>





Latest revision as of 03:34, 11 September 2023


Datensicherung = Backup

Zurück zur
Inhaltsübersicht

#Administration

Who.png Warum?

Es gibt mehrere Gründe, warum es wichtig ist, eine vollständige Instanz/Systemumgebung von Dolibarr zu "sichern".
Beispielsweise:

  • Weil Sie vorhaben, ein Upgrade durchzuführen und bei einem Fehler zur vorherigen Version zurückkehren möchten.
  • Weil Sie Dolibarr von einem Server auf einen anderen Server verschieben/migrieren möchten.
  • Und natürlich, um eine Wiederherstellung machen zu können, wenn etwas Schlimmes passiert ist (Festplattenfehler, Virus, Hack-Angriff, Datenmanipulation ...)

Aus den oben genannten Gründen wird empfohlen, regelmäßig eine neue Sicherungskopie aller von Dolibarr verwendeten und gespeicherten Daten zu erstellen.


Who.png Was ist zu sichern?

Dolibarr speichert seine Daten an 3 unterschiedlichen Speicherorten. Diese müssen alle gesichert werden, bevor man ein Update/Upgrade von Dolibarr durchführt,
um sicher zu stellen, dass man im Notfall wieder den vorherigen Stand wiederherstellen kann.
Dies sind die 3 Arten von zu sichernden Daten:

Konfigurationsdateien

The configuration file should not be modified by upgrade process, but it is more prudent to save it also when you do an upgrade. The configuration file is called conf.php and you can find it into directory dolibarrdir/htdocs/conf/. Make a copy of this file into the dedicated area of your backup.

Note: This backup is however optional as you can still rebuild this file manually from scratch or with the Dolibarr install wizard if you know your database credentials (this file contains only parameters to connect to database and directory where you Dolibarr is installed). When making a restore, it is still possible to rebuild this file by an installation from scratch.

Datenbank

Die Datenbank beinhaltet alle Daten, die man im Dolibarr Programm eingegeben/erzeugt hat, also z.B. Partner, Kontakte, Produkte, Belege, Termine .. (außer angehängte oder durch Belege erzeugte Dokumente).
Die Sicherung der Datenbank muss gesamtheitlich erfolgen (alle Daten/Tabellen).
Es wird empfohlen die Datenbank regelmäßig zu sichern.

Dokumente

Alle Dokumente, die sich auf Ihre Dolibarr-Instanz beziehen, werden in einem Verzeichnis gespeichert, das in Ihrer Konfigurationsdatei definiert ist. dolibarrdir/htdocs/conf/conf.php. Wenn Sie die Auswahl bei der Erstinstallation standardmäßig beibehalten haben, sollte sie etwa so aussehen dolibarrdir/documents. Dieses Verzeichnis muss vollständig gespeichert sein.

Bei einem Upgrade sollte der Upgrade-Prozess dieses Verzeichnis nicht ändern, aber dieses Verzeichnis kann vom Webserver jederzeit gelesen und geschrieben werden, es kann durch eine schlechte Aktion oder einen Fehler geändert werden. Um sicherzustellen, dass Sie alle Ihre verbundenen Dateien behalten und sie wiederherstellen können, wenn sie versehentlich gelöscht oder geändert werden, erstellen Sie einfach eine Kopie des gesamten Inhalts dieses Verzeichnisses.

Hinweis: Das Kopieren des gesamten Ordners mit allen Ihren Dokumenten könnte ein ressourcenintensiver Prozess sein, also wenn Sie dies nicht regelmäßig tun können, machen Sie zumindest ein Backup Ihrer Datenbank (die viel kleiner sein sollte und es Ihnen trotzdem ermöglichen würde, die meisten Ihrer Daten wiederherzustellen, die dann verwendet werden können, um die meisten Ihrer Dokumente zu regenerieren).

Code Änderung

Schließlich sollte jede kundenspezifische Entwicklung von Modulen, d.h. alle php-Dateien (oder andere), die hinzugefügt oder geändert worden wären, um spezifischen Anforderungen gerecht zu werden, ebenfalls gespeichert werden. In den meisten Fällen sind Sie von diesem Punkt nicht betroffen.

Who.png Wann ?

Die Häufigkeit der Backups hängt davon ab, wie oft Sie Dolibarr verwenden und welche Konsequenzen Sie akzeptieren, wenn etwas passiert. Je häufiger die Frequenz der Backups, desto weniger Daten gehen bei einem Crash/Ausfall verloren.

Außerdem haben Sie die Wahl, ob Sie häufiger kritischere Teile (wie die Datenbank) sichern und weniger regelmäßig andere Teile, wie z.B. die Dokumente mit hohem Speicherbedarf.

Als guter Ausgangspunkt sollte Ihre Datenbank je nach Nutzung einmal im Monat oder sogar einmal die Woche gesichert werden, während die Dokumente alle 6 Monate oder einmal im Monat (je nach Nutzung) gesichert werden können.

Die conf.php Datei muss hingegen nur einmal gesichert werden (da sie sich nur ändert, wenn Sie Ihren Host wechseln, und trotzdem manuell erstellt werden kann).

Who.png Wie ?

Die Konfigurationsdatei

Eine einfache Kopie der Datei conf/conf.php in einem Verzeichnis, das für ihr Backup bestimmt ist, genügt.

Die Datenbank

Es gibt 4 Möglichkeiten, Ihre Datenbank zu sichern:

Verwendung des Dolibarr System-Backup-Tools

Dies ist der einfachste Weg, um Ihr Backup zu erstellen, und außerdem werden alle Ihre Backups auf dem Server gespeichert und aufgelistet, so dass Sie jede Version jederzeit abrufen können.

Wenn Sie eine neuere Version von Dolibarr verwenden, melden Sie sich einfach mit einem Administratorkonto bei Dolibarr an (nur Administratoren können Systemtools verwenden).

Gehen Sie anschließend zu Home -> System tools -> Backups. Wählen Sie Ihre Backup Optionen (Sie können alle Standardwerte verwenden).

Alternative: Für die Standardmethode MySQL Dump (mysqldump) ist es notwendig, dass Sie ausführbaren Zugriff auf die mysqldump binary auf ihrem Server haben. Auf einem shared host mit disabled mysqldump usage, können Sie eine andere Method namens MySQL Dump (php) versuchen. Da bei dieser Methode nicht zu 100% gewährleistet ist, dass Ihre Daten korrekt gespeichert werden, stellen Sie das bitte selbst sicher, indem Sie ein Backup machen und dieses in einer lokalen nicht-produktiven Umgebung wiederherstellen.

Using mysqldump

If you prefer a manual mode, you can also use the backup tool designed for your database. With Mysql, the command to backup your database into a file is :

mysqldump -u user -pyourpass --result-file=mysqldump_databasename_version_date.sql databasename

where :

  • user is MySQL user that Dolibarr use to connect to database,
  • yourpass is password of MySQL account user (warning, no space between the p and yourpass),
  • databasename is the name of Dolibarr database.

Those informations (user, password and database) are available into your configuration file dolibarrdir/htdocs/conf/conf.php

The result file ("dump file"), is called mysqldump_databasename_version_date.sql where

  • version is the dolibarr version (ex: 3.7).
  • date can be replaced with a date, recommanded format is YYYYMMDD, with YYYY the year (ex. 2011), MM is month number (ex. 05) and DD is day in month (ex. 18).

With value used as example, we will get a dump file called mysqldump_databasename_3.7_20110518.sql.


If you want to have your file compressed (compressé) :

mysqldump databasename -h host -u user -pyourpass -l --single-transaction -K --add-drop-table=TRUE --tables -c -e --hex-blob --default-character-set=utf8 | bzip2 > mysqldump_databasename_version_date.bz2

Dump file will be generated with a bzip compressed format.

Example:

With Linux, to make a regular backup at 1:30 each day into file mysqldump_databasename_DD.sql.bz2, you can add this into your cron file:

30 1 * * * mysqldump databasename -h host -u user -pyourpass -l --single-transaction -K --add-drop-table=TRUE --tables -c -e --hex-blob --default-character-set=utf8 | bzip2 > mysqldump_databasename_`date +%d`.sql.bz2

Using phpMyAdmin

Do not use phpMyAdmin to save your database ! phpMyAdmin generates some dump files, but if you used default option, you won't be able to restore it. You must enable one specific option for you to be able to restore your backup later on (if you forgot to do so and already have a backup that you want to restore, please read the note about FOREIGN_KEY_CHECKS below).

In phpMyAdmin, click on the tab Export, then select your Dolibarr's database/tables (depending whether you are in multi-database view or tables view), and then enable the option Disable foreign key checks, also check that the output will be SQL, and then you can validate your export. Also, not that, even with this option, backup is NEVER guaruanted with phpMyAdmin and is OFTEN useless. The only secured method is to use mysqldump (from Dolibarr or manually. See the two previous chapters).

Using another Third-Party Tools

You can also use third-party database backup softwares, like php scripts that you can upload on your server (such as db2SQL by Howard Yeend or BigDump), or also use database designer/workbench softwares which generally offer to remotely connect to your database and allow you to make a full backup (along to remotely manage your database).




Warning.png in any case, your sql backup file should disable foreign keys prior to restoring, else your backup won't be restorable because of foreign keys clashing! Eg: Add FOREIGN_KEY_CHECKS in headers and footers:

-- SQL Dump
-- Server version: 5.5.8

SET FOREIGN_KEY_CHECKS=0;
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;

CREATE TABLE IF NOT EXISTS `llx_accountingaccount` (

INSERT INTO ...

CREATE TABLE ...

INSERT INTO ...

...

SET FOREIGN_KEY_CHECKS=1;


Warning.png Mysqldump (using command line tool or using Dolibarr backup tool) is the most secure way to backup your data because it is developed along MySQL and thus is always up-to-date. PhpMyAdmin and other thirdparty tools may generate a correct SQL dump but may be outdated or miss some features (depending on options you choose).

The documents

Just copy the Documents folder (dolibarr/documents by default) to your local backup directory.

Note: If you made a backup of the database with the System Tools of Dolibarr, the sql dump files also resides in the Documents folder, and thus will be copied along.

Astuces.png Restore

This topic is explained into page Restores.