{"id":13523,"date":"2022-06-14T02:43:05","date_gmt":"2022-06-14T00:43:05","guid":{"rendered":"https:\/\/contabo.com\/blog\/?p=13523"},"modified":"2025-01-24T08:16:34","modified_gmt":"2025-01-24T07:16:34","slug":"linux-server-backup-mit-rclone","status":"publish","type":"post","link":"https:\/\/contabo.com\/blog\/de\/linux-server-backup-mit-rclone\/","title":{"rendered":"Manuelle und geplante Backups von Linux Servern mit Rclone"},"content":{"rendered":"\n<figure class=\"wp-block-image size-full is-style-default\"><img loading=\"lazy\" decoding=\"async\" width=\"1200\" height=\"630\" src=\"https:\/\/contabo.com\/blog\/wp-content\/uploads\/2022\/04\/blog-head_1200x630_backup-linux.jpg\" alt=\"\" class=\"wp-image-13613\" srcset=\"https:\/\/contabo.com\/blog\/wp-content\/uploads\/2022\/04\/blog-head_1200x630_backup-linux.jpg 1200w, https:\/\/contabo.com\/blog\/wp-content\/uploads\/2022\/04\/blog-head_1200x630_backup-linux-600x315.jpg 600w, https:\/\/contabo.com\/blog\/wp-content\/uploads\/2022\/04\/blog-head_1200x630_backup-linux-768x403.jpg 768w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><figcaption class=\"wp-element-caption\">Simples Linux Server Backup mit Rclone<\/figcaption><\/figure>\n\n\n\n<p>In diesem Beitrag m\u00f6chte ich dir zeigen, wie Du sowohl manuelle, als auch automatisierte Linux Server Backups mithilfe von Rclone erstellst. Es wird ein Linux-System mit root Zugriff ben\u00f6tigt. Dabei spielt es keine Rolle, ob es sich um einen <a href=\"https:\/\/contabo.com\/de\/dedicated-servers\/\" target=\"_blank\" rel=\"noreferrer noopener\">Dedicated <\/a><a href=\"https:\/\/contabo.com\/de\/dedicated-servers\/\">Server<\/a> oder <a href=\"https:\/\/contabo.com\/de\/vps\/\" target=\"_blank\" rel=\"noreferrer noopener\">VPS <\/a>handelt.<\/p>\n\n\n\n<p><strong>Wichtig: Die folgenden Befehle wurden mit Ubuntu 18.04(64 Bit), Ubuntu 20.04(64 Bit), Debian 9 und Debian 10 getestet. Andere Distributionen wie CentOS erfordern hier und da ein paar Anpassungen.<\/strong><\/p>\n\n\n\n<p>Um die folgenden Befehle auszuf\u00fchren ben\u00f6tigst Du root-Rechte, welche Du dir mit diesem Befehl verschaffen kannst:<\/p>\n\n\n\n<p><code>sudo -i<\/code><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-erste-konfiguration-des-linux-servers\">Erste Konfiguration des Linux Servers<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-1-s3-object-storage-zugangsdaten\">1. S3 Object Storage Zugangsdaten<\/h3>\n\n\n\n<p>Ich werde in diesem Tutorial den Contabo <a href=\"https:\/\/contabo.com\/de\/object-storage\/\" target=\"_blank\" rel=\"noreferrer noopener\">Object <\/a><a href=\"https:\/\/contabo.com\/de\/object-storage\/\">Storage<\/a> als Speicher verwenden.<\/p>\n\n\n\n<p>Zun\u00e4chst werden folgende Zugangsdaten ben\u00f6tigt:<\/p>\n\n\n\n<p>Access_key, secret_key und die S3-URL von Contabo. All diese Daten kannst Du im Abschnitt Object Storage deines <a href=\"https:\/\/my.contabo.com\/\">CCP <\/a>finden.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1249\" height=\"845\" src=\"https:\/\/contabo.com\/blog\/wp-content\/uploads\/2022\/04\/S3-credentials-a833c5b7e8fc8dcef9173da77583479a.png\" alt=\"\" class=\"wp-image-13510\" srcset=\"https:\/\/contabo.com\/blog\/wp-content\/uploads\/2022\/04\/S3-credentials-a833c5b7e8fc8dcef9173da77583479a.png 1249w, https:\/\/contabo.com\/blog\/wp-content\/uploads\/2022\/04\/S3-credentials-a833c5b7e8fc8dcef9173da77583479a-600x406.png 600w, https:\/\/contabo.com\/blog\/wp-content\/uploads\/2022\/04\/S3-credentials-a833c5b7e8fc8dcef9173da77583479a-768x520.png 768w\" sizes=\"auto, (max-width: 1249px) 100vw, 1249px\" \/><figcaption class=\"wp-element-caption\">S3 Object Storage Zugangsdaten im CCP<\/figcaption><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-2-wie-man-eine-linux-sicherungsdatei-erstellt\">2. Wie man eine Linux Sicherungsdatei erstellt<\/h3>\n\n\n\n<p>Zuerst m\u00fcssen wir die neueste Version von rclone mit folgendem Befehl installieren: <\/p>\n\n\n\n<p><code>curl https:\/\/rclone.org\/install.sh | sudo bash<\/code><\/p>\n\n\n\n<p>Mit dem folgenden Befehl erstellen wir ein Backup des aktuell angemeldeten Benutzers und speichern die Backup-Datei mit Datum in Verzeichnis \/opt\/backup\/. Zun\u00e4chst m\u00fcssen wir jedoch das Verzeichnis \/backup\/ mit folgendem Befehl erstellen:<\/p>\n\n\n\n<p><code>mkdir \/opt\/backup\/<\/code><\/p>\n\n\n\n<p><code>cd \/opt\/backup &amp;&amp; tar -cvzf backup-$(date +%d.%m.%Y).tar.gz --directory=\/ --exclude=lost+found --exclude=dev\/* --exclude=proc\/* --exclude=run\/* --exclude=sys\/* --exclude=tmp\/* --exclude=mnt\/* --exclude=media\/* --exclude=opt\/backup\/* .<\/code><\/p>\n\n\n\n<p>Erl\u00e4uterung des Befehls:<\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:100%\">\n<pre class=\"wp-block-code\"><code>tar - tar erstellt uns ein Archiv unserer Daten. In diesem Beispiel mit den folgenden Parametern: \nc - (create) erstellt ein neues Archiv \nv - (verbose) detaillierte Ausgabe \n z - (gzip) das Archiv wird mit gzip komprimiert \n f - (file) Name und Speicherort des Archivs. Muss als letzte Option \u00fcbergeben werden, da alles nach f als Dateipfad behandelt wird.\n\/pfad\/filename.tar.gz - Pfad, in den das Archiv geschrieben wird.  \nWie Sie sehen k\u00f6nnen, habe ich einige Verzeichnisse ausgeschlossen, die wir nicht sichern wollen, aus Gr\u00fcnden des Speicherplatzes oder wegen unerw\u00fcnschter gro\u00dfer Dateien in tmp. <\/code><\/pre>\n<\/div>\n<\/div>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-3-konfiguration-von-rclone\">3. Konfiguration von Rclone<\/h3>\n\n\n\n<p>In diesem Beispiel werden werden die Ordner und Dateien, von denen Du ein Backup erstellen willst, im Verzeichnis \/opt\/backup\/ gespeichert.<\/p>\n\n\n\n<p>Eine Anleitung, wie du Rclone einrichtest findest du <a href=\"https:\/\/help.contabo.com\/en\/support\/solutions\/articles\/103000305592-what-is-the-rclone-tool-\" target=\"_blank\" rel=\"noreferrer noopener\">hier<\/a>.<\/p>\n\n\n\n<p>Nach der Installation k\u00f6nnen wir von unserem Linux Server ein Backup mit Rclone erstellen.<\/p>\n\n\n\n<div class=\"wp-block-group is-layout-flow wp-block-group-is-layout-flow\">\n<div class=\"wp-block-group is-layout-flow wp-block-group-is-layout-flow\"><\/div>\n<\/div>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-4-manuelles-kopieren-des-linux-backups\">4. Manuelles kopieren des Linux Backups<\/h3>\n\n\n\n<p>Ich habe meinen remote Speicherplatz eu2 und meinen Sicherungsordner backup genannt. Nun m\u00fcssen wir einen Bucket erstellen, in dem wir alle Dateien speichern.<\/p>\n\n\n\n<p><code>rclone mkdir eu2:backup<\/code><\/p>\n\n\n\n<p>Nachdem Du alle Schritte im obigen Abschnitt &#8222;Erstkonfiguration&#8220; durchgef\u00fchrt hast, gib folgenden Befehl ein, um die Dateien auf dem Object Storage zu speichern<\/p>\n\n\n\n<p>Alle Daten aus \/opt\/backup werden nun in den Ziel-Bucket \u00fcbertragen.<\/p>\n\n\n\n<p><code>rclone copy -P \/opt\/backup eu2:backup\/<\/code><\/p>\n\n\n\n<p>Kopieren aller Daten.<\/p>\n\n\n\n<p><code>rclone move -P \/opt\/backup eu2:backup\/<\/code><\/p>\n\n\n\n<p>Move l\u00f6scht Dateien nach der \u00dcbertragung.<\/p>\n\n\n\n<p><code>rclone sync -P \/opt\/backup eu2:backup\/<\/code><\/p>\n\n\n\n<p>Sync aktualisiert die Dateien auf dem remote Speicher, gibt aber keinen Platz auf Ihrem Server frei.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-5-planen-von-rclone-backups\">5. Planen von Rclone Backups<\/h3>\n\n\n\n<p>Nachdem Du alle Schritte im obigen Abschnitt &#8222;Erstkonfiguration&#8220; durchgef\u00fchrt hast, kannst Du nun auch die Simplen Linux Backups mit Rclone planen.<\/p>\n\n\n\n<p>Als erstes m\u00fcssen wir eine Skriptdatei erstellen:<\/p>\n\n\n\n<p><code>sudo nano \/var\/rclone.sh<\/code> oder ein Name Ihrer Wahl<\/p>\n\n\n\n<p>Und f\u00fcge folgendes dem Skript hinzu :<\/p>\n\n\n\n<p><code>#!\/bin\/bash<\/code><\/p>\n\n\n\n<p><code>cd \/opt\/backup &amp;&amp; tar -cvzf backup-$(date +%d.%m.%Y).tar.gz --directory=\/ --exclude=lost+found --exclude=dev\/* --exclude=proc\/* --exclude=run\/* --exclude=sys\/* --exclude=tmp\/* --exclude=mnt\/* --exclude=media\/* --exclude=opt\/backup\/* .<\/code><\/p>\n\n\n\n<p><code>\/usr\/bin\/rclone sync -P --update --verbose --transfers 30 --log-file=\/var\/log\/upload.log \"\/opt\/backup\" \"eu2:backup\/\"<\/code><\/p>\n\n\n\n<p>Jetzt machen wir die Datei ausf\u00fchrbar<\/p>\n\n\n\n<p><code>sudo chmod +x \/var\/rclone.sh<\/code><\/p>\n\n\n\n<p>Nun m\u00fcssen wir unserem System mitteilen, wann wir unser Skript ausf\u00fchren wollen<\/p>\n\n\n\n<p><code>sudo crontab -e<\/code><\/p>\n\n\n\n<p>Und f\u00fcgen Folgendes hinzu<\/p>\n\n\n\n<p><code>0 2 * * * \/var\/rclone.sh<\/code><\/p>\n\n\n\n<p>In diesem Beispiel wird die Datei \/var\/rclone.sh jeden Tag um 02:00 Uhr aufgerufen. <\/p>\n\n\n\n<p>Mehr \u00fcber FTP Backup findest du in folgendem <a href=\"https:\/\/contabo.com\/blog\/de\/linux-debianubuntu-backup\/\">Artikel<\/a>.<\/p>\n\n\n\n<p>Du kannst die Uhrzeit und das Datum nach Belieben \u00e4ndern. Wenn Du noch nicht mit cron vertraut bist, findest du hier einen Crontab-Generator, der dir dabei helfen wird.<\/p>\n\n\n\n<p>Das ist der weg um ein Simples Linux Backup mit Rclone durchzuf\u00fchren und zu Planen.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-6-daten-wiederherstellen-mit-rclone\">6. Daten wiederherstellen mit Rclone<\/h3>\n\n\n\n<p><code>rclone copy -P eu2:backup\/ \/opt\/backup<\/code><\/p>\n\n\n\n<p>Um dein Backup herunterzuladen, m\u00fcssen Quelle und Ziel gewechselt und angegeben, welches Backup du runterladen m\u00f6chtest (Solltest du mehrere Backups gespeichert haben z.B Backup-20.04.2022.tar.gz)<\/p>\n\n\n\n<p><strong>Zus\u00e4tzliche Informationen<\/strong><\/p>\n\n\n\n<p>Weitere Informationen \u00fcber <a href=\"https:\/\/rclone.org\/flags\/\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">Flags <\/a>und Konfiguration findest du in der <a href=\"https:\/\/rclone.org\/s3\/\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">offiziellen <\/a><a href=\"https:\/\/rclone.org\/s3\/\" rel=\"nofollow\">Dokumentation<\/a><\/p>\n\n\n\n<p>I<em>n manchen F\u00e4llen muss die Flag -s3-chunk-size 200M zu dem Skript hinzuf\u00fcgt werden, wenn die Upload-Geschwindigkeit sehr langsam ist.<\/em><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Wie man ein einfaches Backup eines Linux Servers erstellt mithilfe von rclone<\/p>\n","protected":false},"author":56,"featured_media":13613,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"_uag_custom_page_level_css":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[1399],"tags":[],"ppma_author":[1526],"class_list":["post-13523","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials"],"uagb_featured_image_src":{"full":["https:\/\/contabo.com\/blog\/wp-content\/uploads\/2022\/04\/blog-head_1200x630_backup-linux.jpg",1200,630,false],"thumbnail":["https:\/\/contabo.com\/blog\/wp-content\/uploads\/2022\/04\/blog-head_1200x630_backup-linux-150x150.jpg",150,150,true],"medium":["https:\/\/contabo.com\/blog\/wp-content\/uploads\/2022\/04\/blog-head_1200x630_backup-linux-600x315.jpg",600,315,true],"medium_large":["https:\/\/contabo.com\/blog\/wp-content\/uploads\/2022\/04\/blog-head_1200x630_backup-linux-768x403.jpg",768,403,true],"large":["https:\/\/contabo.com\/blog\/wp-content\/uploads\/2022\/04\/blog-head_1200x630_backup-linux.jpg",1200,630,false],"1536x1536":["https:\/\/contabo.com\/blog\/wp-content\/uploads\/2022\/04\/blog-head_1200x630_backup-linux.jpg",1200,630,false],"2048x2048":["https:\/\/contabo.com\/blog\/wp-content\/uploads\/2022\/04\/blog-head_1200x630_backup-linux.jpg",1200,630,false]},"uagb_author_info":{"display_name":"Kevin","author_link":"https:\/\/contabo.com\/blog\/de\/author\/kevink\/"},"uagb_comment_info":0,"uagb_excerpt":"Wie man ein einfaches Backup eines Linux Servers erstellt mithilfe von rclone","authors":[{"term_id":1526,"user_id":56,"is_guest":0,"slug":"kevink","display_name":"Kevin","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/6445e432ffc4b2c28a228b7ef8d536965ffc588d2bfedd5e77efab91039a5a8f?s=96&d=mm&r=g","0":null,"1":"","2":"","3":"","4":"","5":"","6":"","7":"","8":""}],"_links":{"self":[{"href":"https:\/\/contabo.com\/blog\/de\/wp-json\/wp\/v2\/posts\/13523","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/contabo.com\/blog\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/contabo.com\/blog\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/contabo.com\/blog\/de\/wp-json\/wp\/v2\/users\/56"}],"replies":[{"embeddable":true,"href":"https:\/\/contabo.com\/blog\/de\/wp-json\/wp\/v2\/comments?post=13523"}],"version-history":[{"count":2,"href":"https:\/\/contabo.com\/blog\/de\/wp-json\/wp\/v2\/posts\/13523\/revisions"}],"predecessor-version":[{"id":21347,"href":"https:\/\/contabo.com\/blog\/de\/wp-json\/wp\/v2\/posts\/13523\/revisions\/21347"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/contabo.com\/blog\/de\/wp-json\/wp\/v2\/media\/13613"}],"wp:attachment":[{"href":"https:\/\/contabo.com\/blog\/de\/wp-json\/wp\/v2\/media?parent=13523"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/contabo.com\/blog\/de\/wp-json\/wp\/v2\/categories?post=13523"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/contabo.com\/blog\/de\/wp-json\/wp\/v2\/tags?post=13523"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/contabo.com\/blog\/de\/wp-json\/wp\/v2\/ppma_author?post=13523"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}