Home Diary Blog Photo Community Open Source
crontab for linux
setttings timezone

cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

$crontab -u root -e

0 3 * * * /data/backup/backup.sh > /dev/null 2>&1


$vim backup.sh

#!/bin/bash

/usr/bin/rsync -avH --no-super --delete --progress --password-file=/etc/rsync.secrets nobody@10.206.80.249::git --exclude=.360cache/ /data/backup/git/

find /data/backup/git/ -mtime +30 -name "*.tar" -exec rm -f {} \;


backup for gitlab

$crontab -u git -e
0 1 * * * cd /home/git/gitlabhq-7.11.4 && PATH=/usr/local/bin:/usr/bin:/bin bundle exec rake gitlab:backup:create RAILS_ENV=production && chmod 755 /data/git/backups/ -R

setttings timezone

cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

$crontab -u root -e

0 3 * * * /data/backup/backup.sh > /dev/null 2>&1


$vim backup.sh

#!/bin/bash

/usr/bin/rsync -avH --no-super --delete --progress --password-file=/etc/rsync.secrets nobody@10.206.80.249::git --exclude=.360cache/ /data/backup/git/

find /data/backup/git/ -mtime +30 -name "*.tar" -exec rm -f {} \;


backup for gitlab

$crontab -u git -e
0 1 * * * cd /home/git/gitlabhq-7.11.4 && PATH=/usr/local/bin:/usr/bin:/bin bundle exec rake gitlab:backup:create RAILS_ENV=production && chmod 755 /data/git/backups/ -R


backup for mysql

#!/bin/bash
 time=`date +%Y-%m-%d`

 /usr/local/mysql/bin/mysqldump -uxxx -pxxx --default-character-set=utf8 cheyi_wx > /data/backup/db_$time.sql