diff --git a/backup_core_local b/backup_core_local new file mode 100755 index 0000000000000000000000000000000000000000..047df4cf3aa9fcc420fe69e502477d75290dc85a --- /dev/null +++ b/backup_core_local @@ -0,0 +1,53 @@ +#!/bin/csh +# For backing up using rsync +# Intended to be called y other scripts e.g. 'rapid_backup' + +if ($#argv != 4) then + echo Wrong number of arguements +else + echo ' ' + echo '------------------' + echo - root_path = $1 + echo - sync_dir = $2 + echo - back_dir = $3 + echo - backuplog = $4 +endif + +set root_path = $1 +set sync_dir = $2 +set back_dir = $3 +set backuplog = $4 + +if (-e $back_dir) then + echo $back_dir exists + exit +else + mkdir $back_dir +endif + +if (-e $sync_dir) then + echo ' ' +else + echo $sync_dir does not exist + exit +endif + +# Sync all of the cruise directory +echo Going to sync: $root_path +echo to: $sync_dir, +echo backup changed files to $back_dir +echo and record in logfile $backuplog, +echo ' ' +echo ------------- >> $backuplog +echo Syncing $root_path to $sync_dir >> $backuplog +echo Start `date` >> $backuplog + +rsync -v -a --delete -b --backup-dir=$back_dir $root_path $sync_dir + +set how_much1 = `du -sm $sync_dir` +set how_much2 = `du -sm $back_dir` +echo done copying +echo Finish `date` >> $backuplog +echo Total size '(Mb)': $how_much1 >> $backuplog +echo Total size '(Mb)': $how_much2 >> $backuplog +echo ------------- >> $backuplog diff --git a/keep_akeake_in_sync b/keep_akeake_in_sync new file mode 100755 index 0000000000000000000000000000000000000000..13be6687af449cd2de40c32bff0a88220fab7f04 --- /dev/null +++ b/keep_akeake_in_sync @@ -0,0 +1,32 @@ +#!/bin/csh + +# Keep 2nd workstation in sync with primary workstation so that could switch in case of problems +# + +# The directores to sync +set dir_list = 'jc174 rapid users' +set local_path = /local/users/pstar/rpdmoc/ +set remote_fs = 'pstar@akeake:' +set remote_path = /local/users/pstar/rpdmoc/ + +foreach dd ($dir_list) + echo ' ' + echo ' -------------- ' + echo Going to sync: $local_path$dd + echo to: $remote_fs$remote_path + echo Start `date` + rsync -v -a --delete $local_path$dd $remote_fs$remote_path +end + +# Sync all of the programs directory +set local_path = /local/users/pstar/programs +set remote_fs = 'pstar@akeake:' +set remote_path = /local/users/pstar/ + +echo ' ' +echo ' -------------- ' +echo Going to sync: $local_path +echo to: $remote_fs$remote_path +echo Start `date` +rsync -v -a --delete $local_path $remote_fs$remote_path + diff --git a/rapid_backup b/rapid_backup new file mode 100755 index 0000000000000000000000000000000000000000..0f6082866b207a499844bddbc9708ece05f0d85a --- /dev/null +++ b/rapid_backup @@ -0,0 +1,135 @@ +#!/bin/csh +# Backup script for use on RAPID cruises +# Data is copied to an external drive connected to main workstation +# Drive mounted in /media +# +# This version by DAS Updated Tue 28th 2017. Edited previous verions used +# for remote backup on RAPID cruises +# 1) syncs data from "cruise" directory, and creates a bakup of all changed files +# 2) syncs data from "rapid/osnap" directory, and creates a bakup of all changed files +# 3) syncs data from "Desktop" directory, and creates a bakup of all changed files +# When change for a new cruise need to change +# - drive names +# - $root +# - $cru + +# Variables for pathnames +set cru = jc174 +set CRU = JC174 +set root = /local/users/pstar/ +set rapiddir = 'rapid' # Could be osnap +set usersdir = 'users' +set progdir = 'programs' +set deskdir = 'Desktop' +set exec_loc = ${root}cruise/data/exec/rapid/ + +# Which drive are we using and is it there? +echo ' ' +echo `date` ' Starting backup' +echo ' ' +#echo -n 'Which disk are you using? Enter '1', '2', or '3': ' +#set drq = $< +set drq = $1 +echo $drq +if ($drq == 1) then + set drive_name = ${CRU}_back_1 +else if ($drq == 2) then + set drive_name = ${CRU}_back_2 +else if ($drq == 3) then + set drive_name = ${CRU}_back_3 +else + echo 'Input not recognised' + exit +endif + +# Drive pathname +set drive_path = '/run/media/pstar/'${drive_name} + +if (-e ${drive_path}) then + echo Drive connected +else + echo ${drive_path} ' Does not seem to be there' +# exit +endif + +# Create a logfile for the backup +set now = `date +%Y%m%d%H%M%S` +set backuplog = ${drive_path}/backup_logs/backup_log_${now} +if (-e $backuplog) then + echo $backuplog exists + exit +else + touch $backuplog +endif + +# ----------------------------------------------------------------- +# First backup the cruise directory +set root_path_cru = ${root}rpdmoc/${cru} +set sync_cru = ${drive_path}/cruise_${cru}_sync_$drq +set back_cru = ${drive_path}/cruise_${cru}_back_$drq/backup_${now} + +# Call the main routine +# ---------------------------------------------------- +${exec_loc}backup_core_local $root_path_cru $sync_cru $back_cru $backuplog +# ---------------------------------------------------- + +# -------------------------------------------------------------------- +# Sync all of the RAPID directory +set now = `date +%Y%m%d%H%M%S` +set root_path_rap = ${root}rpdmoc/$rapiddir +set sync_rap = ${drive_path}/${rapiddir}_${cru}_sync_$drq +set back_rap = ${drive_path}/${rapiddir}_${cru}_back_$drq/backup_${now} + +# Call the main routine +# ---------------------------------------------------- +${exec_loc}backup_core_local $root_path_rap $sync_rap $back_rap $backuplog +# ---------------------------------------------------- + +# -------------------------------------------------------------------- +# Sync all of the users directory +set now = `date +%Y%m%d%H%M%S` +set root_path_users = ${root}rpdmoc/$usersdir +set sync_users = ${drive_path}/${usersdir}_${cru}_sync_$drq +set back_users = ${drive_path}/${usersdir}_${cru}_back_$drq/backup_${now} + +# Call the main routine +# ---------------------------------------------------- +${exec_loc}backup_core_local $root_path_users $sync_users $back_users $backuplog +# ---------------------------------------------------- + +# -------------------------------------------------------------------- +# Sync all of the programs directory +set now = `date +%Y%m%d%H%M%S` +set root_path_prog = $root$progdir +set sync_prog = ${drive_path}/${progdir}_${cru}_sync_$drq +set back_prog = ${drive_path}/${progdir}_${cru}_back_$drq/backup_${now} + +# Call the main routine +# ---------------------------------------------------- +${exec_loc}backup_core_local $root_path_prog $sync_prog $back_prog $backuplog +# ---------------------------------------------------- + +# -------------------------------------------------------------------- +# Sync all of the Desktop directory +set now = `date +%Y%m%d%H%M%S` +set root_path_desk = $root$deskdir +set sync_desk = ${drive_path}/desk_${cru}_sync_$drq +set back_desk = ${drive_path}/desk_${cru}_back_$drq/backup_${now} + +# Call the main routine +# ---------------------------------------------------- +${exec_loc}backup_core_local $root_path_desk $sync_desk $back_desk $backuplog +# ---------------------------------------------------- + +# ------------------------------------------------------------------ +# And finally copy log of backup to the disk +set olog = /backup_logs + +# Don't want to time out on password so check ok now +echo ' ' +echo '-----------------------------' +#echo 'Press return to copy:' $backuplog $root_path_cru$olog +# set qqq = $< +scp $backuplog $root_path_cru$olog +echo ' ' +echo `date` - Backup finished