Commit 04a3d21b authored by Loic Houpert's avatar Loic Houpert
Browse files

edit backup scripts

parent b9e898be
......@@ -19,17 +19,17 @@ set back_dir = $3
set backuplog = $4
if (-e $back_dir) then
echo $back_dir exists
exit
echo ' '
else
mkdir $back_dir
echo $back_dir does not exist and will be created
mkdir $back_dir
endif
if (-e $sync_dir) then
echo ' '
else
echo $sync_dir does not exist
exit
echo $sync_dir does not exist and will be created
mkdir $sync_dir
endif
# Sync all of the cruise directory
......@@ -42,7 +42,11 @@ echo ------------- >> $backuplog
echo Syncing $root_path to $sync_dir >> $backuplog
echo Start `date` >> $backuplog
rsync -v -a --delete --exclude '._*' --exclude '.DS_Store' -b --backup-dir=$back_dir $root_path $sync_dir
# rsync -v -a --delete --exclude '._*' --exclude '.DS_Store' -b --backup-dir=$back_dir $root_path $sync_dir
set now = `date +%Y%m%d%H%M%S`
set backupdir = $back_dir/backup_${now}
rsync -v -ab --backup-dir=$backupdir --delete --exclude '._*' --exclude '.DS_Store' $root_path $sync_dir
set how_much1 = `du -sm $sync_dir`
set how_much2 = `du -sm $back_dir`
......
......@@ -4,10 +4,10 @@
#
# The directores to sync
set dir_list = 'jc192 rapid users'
set local_path = /local/users/pstar/rpdmoc/
set remote_fs = 'pstar@akeake:'
set remote_path = /local/users/pstar/rpdmoc/
set dir_list = 'osnap dy120 programs Desktop'
set local_path = /local/users/pstar/
set remote_fs = 'pstar@192.168.62.111:'
set remote_path = /local/users/pstar/
foreach dd ($dir_list)
echo ' '
......@@ -18,15 +18,4 @@ foreach dd ($dir_list)
rsync -v -a --exclude '._*' --exclude '.DS_Store' --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 --exclude '._*' --exclude '.DS_Store' --delete $local_path $remote_fs$remote_path
#!/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 = dy120
set CRU = DY120
set root = /local/users/pstar/
set rapiddir = 'osnap' # Could be osnap
# set usersdir = 'users'
set progdir = 'programs'
set deskdir = 'Desktop'
set exec_loc = ${root}programs/mexec-exec/
# 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
if (-e ${drive_path}/'backup_logs') then
echo ' '
else
mkdir ${drive_path}/'backup_logs'
endif
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}/${cru}
set sync_cru = ${drive_path}/cruise_${cru}_sync_$drq
set back_cru = ${drive_path}/cruise_${cru}_back_$drq
# 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}/$rapiddir
set sync_rap = ${drive_path}/${rapiddir}_${cru}_sync_$drq
set back_rap = ${drive_path}/${rapiddir}_${cru}_back_$drq
# Call the main routine
# ----------------------------------------------------
${exec_loc}backup_core_local $root_path_rap $sync_rap $back_rap $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
# 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
# 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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment