{"id":64,"date":"2008-11-07T16:57:11","date_gmt":"2008-11-07T15:57:11","guid":{"rendered":"http:\/\/www.askthegerman.com\/?p=64"},"modified":"2023-02-13T07:37:14","modified_gmt":"2023-02-13T06:37:14","slug":"backing-up-a-webspace","status":"publish","type":"post","link":"https:\/\/www.askthegerman.com\/?p=64","title":{"rendered":"Backing up a Webspace"},"content":{"rendered":"<p>Some of the low cost Hosting Providers do not even offer an interface to backup your webspace.<\/p>\n<p>Personally I do think about it as annoying to download all the previous uploaded files again and again through a slow and less reliable FTP Client interface when an easy script executed on the server can do so much quicker for you instead.<\/p>\n<p>To give you an idea what about I&#8217;m talking, I&#8217;ve written together an easy example you may feel free about to use it in your own environment in future.<\/p>\n<p>It is able to do both, creating a local backup in a separate folder on your server, as also to transfer this backup to your local machine or even to another FTP Server on the net: <\/p>\n<p><em>#!\/bin\/bash<br \/>  # FTP Backup by Michael Lohmar<br \/>  # Script: ftpbackup.sh<br \/>  # Author: Michael Lohmar<br \/>  # Contact? info@mikelo.com<\/em><\/p>\n<p><em>if [ $# != 3 ];then<br \/>  echo &quot;&quot;<br \/>  echo &quot;Shell script for backing up one given domain.&quot;<br \/>  echo &quot;Usage: $(basename $0) domain_to_backup [FTP\/NOFTP] [DEL\/NODEL]&quot;<br \/>  echo &quot;&quot;<br \/>  exit<br \/>  fi<\/em><\/p>\n<p><em>version=1.0<\/em><\/p>\n<p><em>##### INSTALL INSTRUCTIONS: STEP 1 #####<br \/>  ##### START ENTER YOUR INFO HERE #####<\/em><\/p>\n<p><em>serverip=yourserver.com<br \/>  # Your remote servers IP address<br \/>  # EG: serverip=192.168.1.1<\/em><\/p>\n<p><em>serveruser=youruser<br \/>  # The FTP login for the remote server<br \/>  # EG: serveruser=bob<\/em><\/p>\n<p><em>serverpass=yourpassword<br \/>  # The FTP password for the remote server<br \/>  # EG: serverpass=mypassword<\/em><\/p>\n<p><em>localdir=\/home\/your\/local\/folder<br \/>  # WHERE LOCAL FILES ARE TO BACKUP<br \/>  # NO TRAILING SLASH<br \/>  # EG: localdir=\/backup\/folder\/daily<\/em><\/p>\n<p><em>sourcedir=\/home\/your\/source\/folder<br \/>  # WHERE LOCAL FILES ARE TO BACKUP<br \/>  # NO TRAILING SLASH<br \/>  # EG: localdir=\/domain\/source\/folder<\/em><\/p>\n<p><em>remotedir=your\/remote\/folder<br \/>  # FTP directory where you want to save files to<br \/>  # This directory must exist on the FTP server!<br \/>  # NO TRAILING SLASH<br \/>  # EG: remotedir=\/serverdirectory<\/em><\/p>\n<p><em>##### END YOUR INFO HERE #####<\/em><\/p>\n<p><em>##### INSTALL INSTRUCTIONS: STEP 2 #####<br \/>  # CHMOD the script to 755: # chmod 755 ftpbackup.sh<\/em><\/p>\n<p><em># Add the script to a scheduled cron job to run as often as you like (if wished!)<\/em><\/p>\n<p><em># In SSH do crontab -e, then paste in the following<br \/>  # 0 6 * * 0,1,3,5 \/home\/admin\/ftpbackup.sh<br \/>  # This does a FTP backup every second day of the week, lookup cronjobs for more info on setting dates and times.<br \/>  # Don&#8217;t forget to substitue the path info to the script with your details<br \/>  ##### INSTALL COMPLETE #####<br \/>  # DO NOT MODIFY ANYTHING BELOW #<\/em><\/p>\n<p><em>host=`hostname`<br \/>  cd $sourcedir<\/em><\/p>\n<p><em>echo &quot;Starting FTP Backup on &quot; $host<\/em><\/p>\n<p><em># Creating a local tar.gz Archive<br \/>  tar cfvz $localdir\/$1_`date +%y_%m_%d`.tar.gz $1<\/em><\/p>\n<p><em># Transfer the tar.gz Archive to remote server<br \/>  if [ $2 == FTP ];then<br \/>  cd $localdir<br \/>  echo &quot;user $serveruser $serverpass<br \/>  cd $remotedir<br \/>  bin<br \/>  verbose<br \/>  put $1_`date +%y_%m_%d`.tar.gz<br \/>  &quot; | ftp -i -n $serverip<br \/>  fi<\/em><\/p>\n<p><em># Delete local tar.gz Archive again<br \/>  if [ $3 == DEL ];then<br \/>  rm $localdir\/$1_`date +%y_%m_%d`.tar.gz<br \/>  fi<\/em><\/p>\n<p><em>echo &quot;Ftp backup complete on &quot; $host<br \/>  exit 0 <br \/> <\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Some of the low cost Hosting Providers do not even offer an interface to backup your webspace. Personally I do think about it as annoying to download all the previous uploaded files again and again through a slow and less reliable FTP Client interface when an easy script executed on the server can do so [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[260,14,31,15,49],"tags":[20,76,80,78,75,79,81,77,74],"class_list":["post-64","post","type-post","status-publish","format-standard","hentry","category-backup","category-operatingsystem","category-tipsntricks","category-unix","category-webtech","tag-backup","tag-ftp","tag-ftp-client","tag-gzip","tag-hosting","tag-remote","tag-server","tag-tar","tag-webspace"],"_links":{"self":[{"href":"https:\/\/www.askthegerman.com\/index.php?rest_route=\/wp\/v2\/posts\/64","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.askthegerman.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.askthegerman.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.askthegerman.com\/index.php?rest_route=\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.askthegerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=64"}],"version-history":[{"count":3,"href":"https:\/\/www.askthegerman.com\/index.php?rest_route=\/wp\/v2\/posts\/64\/revisions"}],"predecessor-version":[{"id":376,"href":"https:\/\/www.askthegerman.com\/index.php?rest_route=\/wp\/v2\/posts\/64\/revisions\/376"}],"wp:attachment":[{"href":"https:\/\/www.askthegerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=64"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.askthegerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=64"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.askthegerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=64"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}