Difference between revisions of "Backup on Linux / OSX"

From ITSwiki
Jump to: navigation, search
[unchecked revision][unchecked revision]
(Mac OSX)
(Linux client (does not work on MAC))
Line 38: Line 38:
 
Mac OSX
 
Mac OSX
  
  cat ~/.ssh/id_dsa.pub | ssh USER@userbackup1.imm.dtu.dk "mkdir -m700 .ssh ; cat - >> .ssh/authorized_keys"
+
  cat ~/.ssh/id_dsa.pub | ssh USER@userbackup1.compute.dtu.dk "mkdir -m700 .ssh ; cat - >> .ssh/authorized_keys"
  
 
Depending on your current ssh setup the mkdir may return "file exists" warning, this does not matter.
 
Depending on your current ssh setup the mkdir may return "file exists" warning, this does not matter.

Revision as of 15:37, 29 April 2014

Backup from Linux/Mac OS


'rzyncbackup' is a small script made to backup users' home directories - and other directories - on their Linux/Mac desktop and/or laptops. The script uses the 'rsync' command and synchronises the home directory against a remote backup directory on a dedicated server (userbackup1). The remote directory will be backed-up to tape by our NetVault backup system.


Download the 'rzyncbackup' script

>>>> here <<<<

After downloading the script then do this:

sudo cp Rzyncbackup.sh /usr/bin/rzyncbackup

sudo chmod 755 /usr/bin/rzyncbackup

NOTE: This works on Linux/Unix/Mac OS.

Most setup instructions can also be seen in the script itself:

more /usr/bin/rzyncbackup

How to setup

Depending on your current ssh usage/connections to DTU Compute systems you may already have a key that you can use. If you don't know then just run all the following steps on your system to be backed up. Replace USER with your DTU Compute username that you use on sunray4/5,sunfire, etc.

Create your ssh key on the local system to be backed up

ssh-keygen -t dsa

Copy this ssh key to userbackup1

Linux client (does not work on MAC)
ssh-copy-id -i ~/.ssh/id_dsa.pub USER@userbackup1.imm.dtu.dk

Mac OSX

cat ~/.ssh/id_dsa.pub | ssh USER@userbackup1.compute.dtu.dk "mkdir -m700 .ssh ; cat - >> .ssh/authorized_keys"

Depending on your current ssh setup the mkdir may return "file exists" warning, this does not matter.

How to test

ssh USER@userbackup1.imm.dtu.dk (should log you in without password)

You should only login on the remote backup server when establishing the initial setup (copying the 'authorized_keys' file) and to find files that you have just deleted by mistake on the local system. Files from a notebook/desktop system should NEVER be touched or changed on the backup server.

Download /Setup

Download the script and save it in your $HOME/bin directory or in the '/usr/bin' directory (you must be 'root' to write in '/usr/bin').

Make the script executable (if you have not done this already - see top-of-page) : chmod 755 /usr/bin/rzyncbackup

The first time the script is run it will prompt for a username on the remote backup server, and create a few configuration files in your home directory. Please note that no backup of data will be performed at this stage. Rerun the script twice in order to create different folders needed for the script. This means that the script needs to be executed 3 times! before performing the first backup.

.myrzyncexclude - List of files/directories to be excluded from backup
.myrzyncfiles   - List of Directories to include in backup
.nisUserName    - Username used to connect to userbackup1

If you need to backup additional diretories then edit the file .myrzyncfiles in your home

If you need to exclude some diretories, i.e. browser Cache/downloads, then edit the file .myrzyncexclude

NB - you list the exclusions RELATIVE to the path you set in .myrzyncfiles

Backup Server Directory Structure

In the /backup directory on the backup server, you will find a directory with your NISusername. Within this directory there will be a directory for the client/laptop that you backed up using this script.

Example:

User 'xyz' has both a desktop and a laptop thus the directory structure on backup server "userbackup1" would look like this:

/backup/xyz/pcxyz/

/backup/xyz/nbxyz/

NOTE

OBS: At the initial setup run the 'rzyncbackup' script 3 times!

The backup server "userbackup1" can also be used when you are not connected to the institute's network so you can maintain your backed-up files even when you are abroad.

The script can be executed when it suits you - it can also be activated via the crontab file. Log files are placed in a '/tmp/USER' directory on the local node and then copied to the remote node.

The first time it is executed it might run for some time as it is copying all your files to the remote server.

A file in the user's home directory on the local system contains the names of the directories to backup. It is called .myrzyncfiles and each line is a directory to backup.

On Mac OS errors can occur because Mac creates these directories/folders: .Trashes .fseventsd and .Spotlight-V100

When these are copied to the backup server they cannot be erased again by the user because the user does not own these folders.

The folders can be removed and the .Trashes folder substituted with an ordinary file called .Trashes - the .fseventsd folder can be

substituted with a new folder created by the user and an empty file in the folder called 'no_log'

To prevent the Mac OS from doing indexing a file called .metadata_never_index can be created.

 Example #1:
/home/xyz/
(the users home directory)
Example #2:
/Users/xyz/
(Mac users home directory)
Example #3:
/home/xyz/
/usr/local/
(the users home directory plus directory '/usr/local')

The first time the script is being executed the '.myrzyncfiles' file is created automatically with a default entry of the users home directory.

The local directory cannot be a soft link but an actual location: if you have called your local directory for '/users/xyz' and the actual location is '/data/userhome/xyz' and '/users/xyz' is a soft link pointing to that then you must enter the actual physical location (otherwise only a soft link will be copied).