Use your FTP/SSH account as a backup service (Part 1)
If you have a tradebit account or a hosting account somewhere else, does not matter, if you want to backup your data from one server to another: if you host on Linux, you probably already have all you need.
Let’s say you want to backup your web directory on a daily basis:
- Web directory is in /wwwroot/mysite.xy/
- You have access to your server with SSH
- Login to your webserver, e.g. using putty
- Create a text file, e.g. with vi /wwwroot/backup.sh
#!/bin/bash
cd /wwwroot
tar -cvzf myarchive.tgz mysite.xy/
These 2 lines mean: go to the /wwwroot directory and create a file archive with all the files from mysite.xy - Allow this text file to be executed as a shell command: “chmod a+x /wwwroot/backup.sh”
- Now create a cron entry, an entry that is executed on a pre-configured time:
0 5 * * * /wwwroot/backup.sh
Which means: every day at ZERO minutes, 5 o’clock - the order is: minutes, hours, days, month, years
Now you have a daily creation of the the backup archive, which is still in the /wwwroot directory. Tomorrow we will work on the copying to another server automatically!


