Bash shell script and cron job to make tar
backup file (such as 2017-06-27.tar)
If you would like to make a backup file every day, just write like
following script.
The following file_backup.sh bash script makes tar archive file
every day.
$ cat
/root/file_backup.sh #!/bin/bash # Example, MY_DATE:
2017-06-27 set MY_DATE =
`date -d "-1 days" +%Y-%m-%d` echo "date
: $MY_DATE" cd /root/data_dir # Following command makes tar file which contains ‘peter’
subdirectory and file name is *2017-06-28* find
./*/*/peter/ -name "*$MY_DATE*" -print | tar cfz
./daily_compress/SAINT_$MY_DATE.tar --files-from - |
And then, configure cron table like
followings
This cron job runs /root/file_backup.sh 03:00
AM every day
$ contab –e 00 03 * * *
/root/file_backup.sh |
댓글 없음:
댓글 쓰기