{"id":287,"date":"2020-11-16T19:00:31","date_gmt":"2020-11-16T19:00:31","guid":{"rendered":"https:\/\/tomtechproductions.be\/?p=287"},"modified":"2020-11-16T19:00:31","modified_gmt":"2020-11-16T19:00:31","slug":"backup-files-linux","status":"publish","type":"post","link":"https:\/\/blog.tomtechproductions.be\/index.php\/2020\/11\/16\/backup-files-linux\/","title":{"rendered":"Backup files linux"},"content":{"rendered":"\n<p>An easy way to backup files to a local share<\/p>\n\n\n\n<p>The example backup&#8217;s the files from the \/var\/www\/html directory<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#change to website folders\ncd \/var\/www\/html\/\n\n#find all subsites\nfor D in *; do\n    if &#91; -d \"${D}\" ]; then\n        echo \"Generating backup for $D > \" `date +%Y-%m-%d_%H-%M-%S`-${D}   # your processing here\n        tar -zcvf \"\/mnt\/srv-ttp-nas\/server\/\"`date +%Y-%m-%d_%H-%M-%S`-${D}.tar.gz ${D}\n    fi\ndone\n\n#remove stale files\nfind \/mnt\/srv-ttp-nas\/server\/* -mtime +14 -exec rm {} \\;<\/code><\/pre>\n\n\n\n<p><strong>Add crontab to run backup every night at 3<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo crontab -e\n0 3 * * * \/home\/tom\/backup_files.sh<\/code><\/pre>\n\n\n\n<p>Preview of data on share<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"498\" src=\"https:\/\/tomtechproductions.be\/wp-content\/uploads\/2020\/11\/image-2-1024x498.png\" alt=\"\" class=\"wp-image-290\" srcset=\"https:\/\/blog.tomtechproductions.be\/wp-content\/uploads\/2020\/11\/image-2-1024x498.png 1024w, https:\/\/blog.tomtechproductions.be\/wp-content\/uploads\/2020\/11\/image-2-300x146.png 300w, https:\/\/blog.tomtechproductions.be\/wp-content\/uploads\/2020\/11\/image-2-768x373.png 768w, https:\/\/blog.tomtechproductions.be\/wp-content\/uploads\/2020\/11\/image-2.png 1099w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>An easy way to backup files to a local share The example backup&#8217;s the files from the \/var\/www\/html directory Add crontab to run backup every night at 3 Preview of data on share<\/p>\n","protected":false},"author":1,"featured_media":286,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[15,20,23,29],"class_list":["post-287","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-geen-categorie","tag-backup","tag-crontab","tag-files","tag-linux"],"_links":{"self":[{"href":"https:\/\/blog.tomtechproductions.be\/index.php\/wp-json\/wp\/v2\/posts\/287","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.tomtechproductions.be\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.tomtechproductions.be\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.tomtechproductions.be\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.tomtechproductions.be\/index.php\/wp-json\/wp\/v2\/comments?post=287"}],"version-history":[{"count":0,"href":"https:\/\/blog.tomtechproductions.be\/index.php\/wp-json\/wp\/v2\/posts\/287\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.tomtechproductions.be\/index.php\/wp-json\/wp\/v2\/media\/286"}],"wp:attachment":[{"href":"https:\/\/blog.tomtechproductions.be\/index.php\/wp-json\/wp\/v2\/media?parent=287"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.tomtechproductions.be\/index.php\/wp-json\/wp\/v2\/categories?post=287"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.tomtechproductions.be\/index.php\/wp-json\/wp\/v2\/tags?post=287"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}