⚲
Project
General
Profile
Sign in
Home
Projects
Help
Search
:
General Info
All Projects
General Info
Overview
Activity
Issues
Gantt
Calendar
News
Documents
Wiki
Files
Download (1.14 KB)
Backup Strategies on cwyrnd3-server
» backup.sh
chin-yeh
, 03/12/2012 01:36 PM
#!/bin/bash
#
# Backup files to remote server.
#
# Must configure the password-less login between local and remote server.
#
# temp workspace
tmp_ws
=
/tmp/backup
# today's date
today_dt
=
$(
date
+%Y-%m-%d
)
# files to be backup
# application, data, log and etc.
app_dir
=
/opt
data_dir
=
/data
log_dir
=
/var/ecosway
# remote backup destination
remote_ip
=
192.168.2.68
remote_user
=
support
remote_dest_dir
=
/data_bak/cwyrnd3-server
if
[
!
-d
${
tmp_ws
}
]
;
then
mkdir
${
tmp_ws
}
fi
# backup redmine db
sh /opt/scripts/backup_redmine_db.sh
# compress the files
echo
"Compressing
$app_dir
"
tar
-cvzf
${
tmp_ws
}
/
${
today_dt
}
.applications.tgz
${
app_dir
}
# compress data files
echo
"Compressing
$data_dir
"
tar
-cvzf
${
tmp_ws
}
/
${
today_dt
}
.data.tgz
${
data_dir
}
# compress log files
echo
"Compressing
$log_dir
"
tar
-cvzf
${
tmp_ws
}
/
${
today_dt
}
.log.tgz
${
log_dir
}
echo
"Compression is completed."
# transfer files to remote server
echo
"Transferring file(s) to
$remote_ip
:
$remote_dest_dir
"
scp /tmp/backup/
${
today_dt
}*
.tgz
${
remote_user
}
@
${
remote_ip
}
:
$remote_dest_dir
echo
"Transfer is completed"
# remove the temp files
echo
"Remove temp files..."
rm
-f
${
tmp_ws
}
/
${
today_dt
}*
« Previous
1
2
Next »
(1-1/2)
Loading...