36 lines
833 B
Bash
Executable File
36 lines
833 B
Bash
Executable File
#!/bin/sh
|
||
|
||
# Purpose :
|
||
# Create an XZ archive of all files between 2 dates.
|
||
# Then remove these files
|
||
|
||
# Call this script from an /var/lib/xymon/hostdata subdirectory.
|
||
|
||
# Vars {{{
|
||
## Enable (0) or disable (1) debug
|
||
debug=0
|
||
|
||
## Manage files of year
|
||
date_year="2019"
|
||
|
||
## Compress files between these dates
|
||
date_start="${date_year}-01-01 00:00:01"
|
||
date_end="${date_year}-12-31 23:59:59"
|
||
|
||
## Best XZ compression level (= -9)
|
||
xz_compression_lvl="--best"
|
||
## Fatest XZ compression level (= -0)
|
||
#xz_compression_lvl="--fast"
|
||
|
||
## Get current directory name
|
||
current_dir=${PWD##*/}
|
||
|
||
## Archive name
|
||
tar_file_name="${date_year}.${current_dir}.tar.xz"
|
||
|
||
# }}}
|
||
|
||
[ "${debug}" -eq "0" ] && printf '%b' "Create an archive for ${current_dir} files between ${date_start} and ${date_end} using XZ's compression level : ${xz_compression_lvl}."
|
||
|
||
exit 0
|