{"id":1092,"date":"2022-06-19T13:28:17","date_gmt":"2022-06-19T11:28:17","guid":{"rendered":"https:\/\/apfelcast.com\/?p=1092"},"modified":"2022-06-19T13:28:17","modified_gmt":"2022-06-19T11:28:17","slug":"die-effizienteste-backup-loesung-fuer-nextcloud-datensicherung-mit-borgbackup","status":"publish","type":"post","link":"https:\/\/it-ion.de\/index.php\/2022\/06\/19\/die-effizienteste-backup-loesung-fuer-nextcloud-datensicherung-mit-borgbackup\/","title":{"rendered":"Die effizienteste Backup L\u00f6sung f\u00fcr NEXTCLOUD &#8211; Datensicherung mit BorgBackup"},"content":{"rendered":"\n<div class=\"brlbs-cmpnt-container brlbs-cmpnt-content-blocker brlbs-cmpnt-with-individual-styles\" data-borlabs-cookie-content-blocker-id=\"default\" data-borlabs-cookie-content=\"PGlmcmFtZSB0aXRsZT0iWW91VHViZSB2aWRlbyBwbGF5ZXIiIHNyYz0iaHR0cHM6Ly93d3cueW91dHViZS5jb20vZW1iZWQvdzJFNjkxRjU3SGsiIHdpZHRoPSI1NjAiIGhlaWdodD0iMzE1IiBmcmFtZWJvcmRlcj0iMCIgYWxsb3dmdWxsc2NyZWVuPSJhbGxvd2Z1bGxzY3JlZW4iPjwvaWZyYW1lPg==\">\n<div class=\"brlbs-cmpnt-cb-preset-a\">\n<p class=\"brlbs-cmpnt-cb-description\">Sie sehen gerade einen Platzhalterinhalt von <strong>Standard<\/strong>. Um auf den eigentlichen Inhalt zuzugreifen, klicken Sie auf die Schaltfl\u00e4che unten. Bitte beachten Sie, dass dabei Daten an Drittanbieter weitergegeben werden.<\/p>\n<div class=\"brlbs-cmpnt-cb-buttons\"> <a class=\"brlbs-cmpnt-cb-btn\" href=\"#\" data-borlabs-cookie-unblock role=\"button\">Inhalt entsperren<\/a> <a class=\"brlbs-cmpnt-cb-btn\" href=\"#\" data-borlabs-cookie-accept-service role=\"button\" style=\"display: none\">Erforderlichen Service akzeptieren und Inhalte entsperren<\/a> <\/div>\n<p> <a class=\"brlbs-cmpnt-cb-provider-toggle\" href=\"#\" data-borlabs-cookie-show-provider-information role=\"button\">Mehr Informationen<\/a> <\/div>\n<\/div>\n<p>Ein ordentliches Backup ist f\u00fcr eine jeden Nextcloud User ein Muss. Mit die effizienteste Backup L\u00f6sung f\u00fcr eine Nextcloud ist aktuell die Anwendung BorgBackup, welche verschl\u00fcsselte, komprimierte und inkrementelle Backups bietet.<\/p>\n<p>\u00bb Relevante Videos:<br \/>\nNextcloud Backup Skript V1: <a href=\"https:\/\/www.youtube.com\/watch?v=_uB9pdnn-gs\">https:\/\/www.youtube.com\/watch?v=_uB9pdnn-gs<\/a><br \/>\nNextcloud Backup App: <a href=\"https:\/\/www.youtube.com\/watch?v=oB10NfuTZCs\">https:\/\/www.youtube.com\/watch?v=oB10NfuTZCs<\/a><br \/>\nNextcloud auf Linux Server installieren: <a href=\"https:\/\/youtu.be\/8Hw7M7tcI9o\">https:\/\/youtu.be\/8Hw7M7tcI9o<\/a><br \/>\nNextcloud Playlist: <a href=\"https:\/\/www.youtube.com\/watch?v=mlRAaZT53Rg&amp;list=PLLg1WgOBYXOtQOwYQjJc1GbuYz-wJgmtN\">https:\/\/www.youtube.com\/watch?v=mlRAaZT53Rg&amp;list=PLLg1WgOBYXOtQOwYQjJc1GbuYz-wJgmtN<\/a><\/p>\n<div id=\"93964-1\"><script src=\"\/\/ads.themoneytizer.com\/s\/gen.js?type=1\"><\/script><script src=\"\/\/ads.themoneytizer.com\/s\/requestform.js?siteId=93964&#038;formatId=1\"><\/script><\/div>\n<p>&nbsp;<\/p>\n<h3>Im Video verwendete Befehle:<\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">##### Nextcloud Borg Backup #####\n\n## mount NAS and create directories ##\nmkdir -p \/backup\/daten \/backup\/temp \/restore\n\n## install borg backup ##\napt install -y borgbackup\n\n## create now Backup Repository ##\nborg init -e repokey-blake2 \/backup\/daten\/\n\n## adjust backup skript und paste ##\nnano \/root\/backup.sh\n\n## make executable ##\nchmod +x \/root\/backup.sh\n\n## automate skript at 03:00 ## \ncrontab -e\n0 3 * * * \/root\/backup.sh &gt; \/dev\/null 2&gt;&amp;1\n\n## list created backups ##\nborg list \/backup\/daten\n\n## mount backup to browse it ##\nborg mount \/backup\/daten::&lt;date&gt; \/restore\/\n\nexample: borg mount \/backup\/daten::20200602_084033 \/restore\/\n\n## unmount the backup ##\nborg umount \/restore\/<\/pre>\n<h3>Skript:<\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"raw\">#!\/bin\/bash\n##################################\n### Beispieldaten:\n### logDirectory=\"\/backup_logs\/\"\n### backupDiscMount=\"\/backup\/\"\n### localBackupDir=\"\/backup\/temp\"\n##################################\nexport BORG_PASSPHRASE='&lt;borg-password&gt;'\nexport BORG_UNKNOWN_UNENCRYPTED_REPO_ACCESS_IS_OK=yes\nexport BORG_RELOCATED_REPO_ACCESS_IS_OK=yes\nstartTime=$(date +%s)\ncurrentDate=$(date --date @\"$startTime\" +\"%Y%m%d_%H%M%S\")\ncurrentDateReadable=$(date --date @\"$startTime\" +\"%d.%m.%Y - %H:%M:%S\")\nlogDirectory=\"\/var\/log\/\"\nlogFile=\"${logDirectory}\/${currentDate}.log\"\nbackupDiscMount=\"\/backup\/daten\/\"\nlocalBackupDir=\"\/backup\/temp\"\nborgRepository=\"${backupDiscMount}\/\"\nborgBackupDirs=\"\/home\/data\/ \/var\/www\/nextcloud\/ $localBackupDir\/\"\nnextcloudFileDir='\/var\/www\/nextcloud'\nwebserverServiceName='apache2'\nwebserverUser='www-data'\nnextcloudDatabase='nextcloud'\ndbUser='root'\ndbPassword='&lt;db-password&gt;'\nfileNameBackupDb='nextcloud-db.sql'\nif [ ! -d \"${logDirectory}\" ]\nthen\n    mkdir -p \"${logDirectory}\"\nfi\nerrorecho() { cat &lt;&lt;&lt; \"$@\" 1&gt;&amp;2; }\nexec &gt; &gt;(tee -i \"${logFile}\")\nexec 2&gt;&amp;1\nif [ \"$(id -u)\" != \"0\" ]\nthen\n    errorecho \"ERROR: This script has to be run as root!\"\n    exit 1\nfi\nif [ ! -d \"${localBackupDir}\" ]\nthen\n    errorecho \"ERROR: The local backup directory ${localBackupDir} does not exist!\"\n    exit 1\nfi\necho -e \"\\n###### Start des Backups: ${currentDateReadable} ######\\n\"\necho -e \"Daten werden zusammengestellt\"\ndpkg --get-selections &gt; \"${localBackupDir}\/software.list\"\nsudo -u \"${webserverUser}\" php ${nextcloudFileDir}\/occ maintenance:mode --on\necho \"apache2 wird gestoppt\"\nsystemctl stop \"${webserverServiceName}\"\necho \"Datenbanksicherung wird erstellt\"\nmysqldump --single-transaction --routines -h localhost -u \"${dbUser}\" -p\"${dbPassword}\" \"${nextcloudDatabase}\" &gt; \"${localBackupDir}\/${fileNameBackupDb}\"\necho -e \"\\nBackup mit borgbackup\"\nborg create --stats \\\n    $borgRepository::\"${currentDate}\" \\\n    $localBackupDir \\\n    $borgBackupDirs \necho\necho \"webserver wird gestartet\"\nsystemctl start \"${webserverServiceName}\"\nsudo -u \"${webserverUser}\" php ${nextcloudFileDir}\/occ maintenance:mode --off\nrm \"${localBackupDir}\"\/software.list\nrm -r \"${localBackupDir}\/${fileNameBackupDb}\"\nborg prune --progress --stats $borgRepository --keep-within=7d --keep-weekly=4 --keep-monthly=6\nendTime=$(date +%s)\nendDateReadable=$(date --date @\"$endTime\" +\"%d.%m.%Y - %H:%M:%S\")\nduration=$((endTime-startTime))\ndurationSec=$((duration % 60))\ndurationMin=$(((duration \/ 60) % 60))\ndurationHour=$((duration \/ 3600))\ndurationReadable=$(printf \"%02d Stunden %02d Minuten %02d Sekunden\" $durationHour $durationMin $durationSec)\necho -e \"\\n###### Ende des Backups: ${endDateReadable} (${durationReadable}) ######\\n\"\necho -e \"Plattenbelegung:\\n\"\ndf -h ${backupDiscMount}<\/pre>\n<p>&nbsp;<\/p>\n<p>\u00bb Quellen &amp; Credits:<br \/>\n<a href=\"https:\/\/www.c-rieger.de\/backup-mit-de-duplizierung\/\">https:\/\/www.c-rieger.de\/backup-mit-de-duplizierung\/<\/a><br \/>\n<a href=\"https:\/\/www.reddit.com\/r\/HomeServer\/comments\/kl2du2\/offsite_nextcloud_backup_using_borgduplicatirsync\/\">https:\/\/www.reddit.com\/r\/HomeServer\/comments\/kl2du2\/offsite_nextcloud_backup_using_borgduplicatirsync\/<\/a><\/p>\n<h3>apfelcast Support<\/h3>\n<p>Du ben\u00f6tigst Unterst\u00fctzung bei deinem Projekt oder hast Fragen zur Umsetzung?<br \/>\n<strong>Dann melde ich gern bei uns!<\/strong><\/p>\n<p>[button link=&#8220;https:\/\/apfelcast.com\/kontakt&#8220; type=&#8220;big&#8220; class=&#8220; custom-button&#8220;] Kontaktieren[\/button]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sie sehen gerade einen Platzhalterinhalt von Standard. Um auf den eigentlichen Inhalt zuzugreifen, klicken Sie&#8230;<\/p>\n","protected":false},"author":1,"featured_media":1093,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_kad_blocks_custom_css":"","_kad_blocks_head_custom_js":"","_kad_blocks_body_custom_js":"","_kad_blocks_footer_custom_js":"","_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","footnotes":""},"categories":[1],"tags":[],"class_list":["post-1092","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-allgemein"],"taxonomy_info":{"category":[{"value":1,"label":"Allgemein"}]},"featured_image_src_large":["https:\/\/it-ion.de\/wp-content\/uploads\/2022\/06\/thumbnail_nc_borg-backup-1024x576.jpg",1024,576,true],"author_info":{"display_name":"Daniel Klozb\u00fccher","author_link":"https:\/\/it-ion.de\/index.php\/author\/wp-master\/"},"comment_info":0,"category_info":[{"term_id":1,"name":"Allgemein","slug":"allgemein","term_group":0,"term_taxonomy_id":1,"taxonomy":"category","description":"","parent":0,"count":89,"filter":"raw","cat_ID":1,"category_count":89,"category_description":"","cat_name":"Allgemein","category_nicename":"allgemein","category_parent":0}],"tag_info":false,"_links":{"self":[{"href":"https:\/\/it-ion.de\/index.php\/wp-json\/wp\/v2\/posts\/1092","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/it-ion.de\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/it-ion.de\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/it-ion.de\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/it-ion.de\/index.php\/wp-json\/wp\/v2\/comments?post=1092"}],"version-history":[{"count":0,"href":"https:\/\/it-ion.de\/index.php\/wp-json\/wp\/v2\/posts\/1092\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/it-ion.de\/index.php\/wp-json\/wp\/v2\/media\/1093"}],"wp:attachment":[{"href":"https:\/\/it-ion.de\/index.php\/wp-json\/wp\/v2\/media?parent=1092"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/it-ion.de\/index.php\/wp-json\/wp\/v2\/categories?post=1092"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/it-ion.de\/index.php\/wp-json\/wp\/v2\/tags?post=1092"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}