Since getting more and more settings, setups and server/machines all over the house and other places, I decided to build me a BackupServer, and started out thinking about what to use to that. And ended up with a Linksys NSLU2.
|
Here's the little machine. You can allso use it for ?? MythBackend-server - BUT that sounds a little funny to me. but my plan was having this little machine to make a backup ogf all of my servers and setups. Configurationsfiles, MySQL dumps etc will afterwards be placed here on the NSLU2. |
![]() |
But first of all - we need to make sure that some requirenments are fullfilled.Starting with a setup of the SSH-keys, which brings us down the level, where a specific machine are allowed to login without password. So let's start out with that problem:
| $ ssh-keygen -t dsa |
This prompts you for a password , if you uses a keyring or anything like that - you can add a password - BUT if you want automatic login (without prompt for passwd) you should just press ENTER twice(no password).
This command generate 2files id_dsa & id_dsa.pub in your .ssh/ dir. Now you sjould copy id_dsa.pub into a file on the remote machine with this command:
| $ scp .ssh/id_dsa.pub IPADDRES:.ssh/authorized_keys |
enter the password - and the copy are placed on the remote machine. Now try login to the same machine again, and you will not be prompted at loginpassword now. This will normally overwrite the file uthorized_keys (if any hosts sere added in there before this)
For getting the backup working I've made som changes, since I have my network through 3different subnet's without direct access through the subnets. The next problem is gaining root access for the backup user - for making the different backups and securering the data. - But ended up with this script:
|
#!/bin/bash # Define the different variables # Commands used during Backup echo "`date +%R:%S `: Starting up the backup process." > $LOGFILE # Starting the Backup (Remember to use SSH-keys) # Firewall / DNs / Nagios etc echo "Backing up the needed configurations at Firewall." >> $LOGFILE echo " " >> $LOGFILE # Web / mail / Wiki echo "Backing up the needed configurations on Webserver." >> $LOGFILE # MythTV - MasterBackend Server echo "Backing up CORE - MythTV server." >> $LOGFILE # EXTRA echo "Backing up Extra server." >> $LOGFILE # Sending the details in a mail! echo "Ended backup procedure..." >> $LOGFILE mail -s 'Daily Backup Backy' "Your emailaddress < $TMP rm -rf /var/log/backup.log # EOF |
This script is placed on the NSLU2(called Backy) and run each nigth at 2AM !
So as you can see - we need som different requirements for this script, so starting with Firewall, so start the backupscript with the requirements needed for running the main backupscript. The preparebackupscript is runned each nigth at 01AM on Aladin (Firewall).
|
#!/bin/bash # Copying the motd # Copying the Firewall script # Copying the DHCP configuration # Copying the DNS directory # Copying Nagios directory # Ending the backup by changing the owner |
So all in all - the backupscript is making the directory, which placed everything for backup - in the dir /home/peque/backup. Afterwards the backupscript on the NSLU2 rsyncs the dir to it self, and afterwards deletes the dir, so it's ready for the next nigth.
The same procedure is runned on the Webserver - at little script on the local server prepares the data for backup. So the script on Atlantis looks like this:
|
#!/bin/bash # Starting scripting # Starting with copying the motd # Rsyncing /var/www # Rsyncing maildir from postfix # Backing up the PostgreSQL database # Backing up the MySQL database # Ending the script by changing the ownership |
This script is starting at 01AM, and afterwards just waiting for the Backy server to connect and syncronize before deleting the files again!
Those 2 servers where the diffucult ones, since I could not hit those machines directky carse of the network setup.
Well - there isn't much to say about this one - carse they're on the same subnet, and direct contact is possible, so just syncronize whatever you want from the CORE server on to the NSLU2.
Afterwards you have your own Backup-system, running automaticly each nigth and even confirms it to you in a mail from the system aboput how it went!
Good luck building your own Backkup-system!