Skip to content

Commit

Permalink
add backup history script
Browse files Browse the repository at this point in the history
Signed-off-by: HuangYong <[email protected]>
  • Loading branch information
newfriday committed Apr 20, 2019
1 parent fdfb5cf commit aeed1b5
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
7 changes: 7 additions & 0 deletions backup_history.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
DATE="$(date "+%d_%m_%y")"

src="/root/.bash_history"
dst="/home/data/history_backup/${DATE}_history_backup"

cp -f ${src} ${dst}
21 changes: 21 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,26 @@ function load_tmux()
[ -f /root/.tmux.conf ] || cp "$ROOT/tmux.conf" /root/.tmux.conf
}

function load_mybash()
{
mkdir -p /usr/bin/mybash

cat /etc/profile | grep mybash
if [ $? -ne 0 ]; then
echo "export PATH=\${PATH}:/usr/bin/mybash" >> /etc/profile
source /etc/profile
fi

chmod +x backup_history.sh
cp -f backup_history.sh /usr/bin/mybash/

cat /etc/crontab | grep mybash
if [ $? -ne 0 ]; then
echo "0 19 * * 6 /usr/bin/mybash/backup_history.sh" >> /etc/crontab
service crond restart > /dev/null 2>&1
fi
}

function config_centos()
{
cp -f "$ROOT/iptables.rules" /etc/sysconfig/iptables.rules
Expand All @@ -49,6 +69,7 @@ function config_ubuntu()

load_vim
load_tmux
load_mybash

if [ "X$ARCH" == "Xcentos" ]; then
echo "config centos ..."
Expand Down

0 comments on commit aeed1b5

Please sign in to comment.