|
|
|
@@ -23,7 +23,6 @@ LOG_OUTPUT="tee -a $LOG2RAM_LOG"
|
|
|
|
|
|
|
|
|
|
|
|
isSafe () {
|
|
|
|
isSafe () {
|
|
|
|
[ -d $HDD_LOG ] || (echo "ERROR: $HDD_LOG doesn't exist! Can't sync." >&2 ; exit 1)
|
|
|
|
[ -d $HDD_LOG ] || (echo "ERROR: $HDD_LOG doesn't exist! Can't sync." >&2 ; exit 1)
|
|
|
|
NoCache=$(command -v nocache 2>/dev/null)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
RecreateLogs (){
|
|
|
|
RecreateLogs (){
|
|
|
|
@@ -48,7 +47,7 @@ syncToDisk () {
|
|
|
|
echo -e "\n\n$(date): Syncing logs to storage\n" | $LOG_OUTPUT
|
|
|
|
echo -e "\n\n$(date): Syncing logs to storage\n" | $LOG_OUTPUT
|
|
|
|
|
|
|
|
|
|
|
|
if [ "$USE_RSYNC" = true ]; then
|
|
|
|
if [ "$USE_RSYNC" = true ]; then
|
|
|
|
${NoCache} rsync -aXWv \
|
|
|
|
rsync -aXWv \
|
|
|
|
--exclude "lost+found" --exclude armbian-ramlog.log \
|
|
|
|
--exclude "lost+found" --exclude armbian-ramlog.log \
|
|
|
|
--exclude 'journal*' --one-file-system \
|
|
|
|
--exclude 'journal*' --one-file-system \
|
|
|
|
--links \
|
|
|
|
--links \
|
|
|
|
@@ -56,7 +55,7 @@ syncToDisk () {
|
|
|
|
$RAM_LOG/ $HDD_LOG/ 2>&1 | $LOG_OUTPUT
|
|
|
|
$RAM_LOG/ $HDD_LOG/ 2>&1 | $LOG_OUTPUT
|
|
|
|
else
|
|
|
|
else
|
|
|
|
rm -f $RAM_LOG/journal # linked journal cannot copied onto itself, it will be re-created below
|
|
|
|
rm -f $RAM_LOG/journal # linked journal cannot copied onto itself, it will be re-created below
|
|
|
|
${NoCache} cp -rfup $RAM_LOG -T $HDD_LOG 2>&1 | $LOG_OUTPUT
|
|
|
|
cp -rfup $RAM_LOG -T $HDD_LOG 2>&1 | $LOG_OUTPUT
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if [ ! -L $RAM_LOG/journal ] && [ -d $RAM_LOG/journal ]; then # move persistent journal to disk
|
|
|
|
if [ ! -L $RAM_LOG/journal ] && [ -d $RAM_LOG/journal ]; then # move persistent journal to disk
|
|
|
|
systemctl stop systemd-journald # journal folder can be in use
|
|
|
|
systemctl stop systemd-journald # journal folder can be in use
|
|
|
|
@@ -83,7 +82,7 @@ syncFromDisk () {
|
|
|
|
echo -e "\n\n$(date): Loading logs from storage\n" | $LOG_OUTPUT
|
|
|
|
echo -e "\n\n$(date): Loading logs from storage\n" | $LOG_OUTPUT
|
|
|
|
|
|
|
|
|
|
|
|
if [ "$USE_RSYNC" = true ]; then
|
|
|
|
if [ "$USE_RSYNC" = true ]; then
|
|
|
|
${NoCache} rsync -aXWv --delete \
|
|
|
|
rsync -aXWv --delete \
|
|
|
|
--exclude "lost+found" --exclude armbian-ramlog.log \
|
|
|
|
--exclude "lost+found" --exclude armbian-ramlog.log \
|
|
|
|
--exclude '*.gz' --exclude '*.xz' --exclude='*.[0-9]' \
|
|
|
|
--exclude '*.gz' --exclude '*.xz' --exclude='*.[0-9]' \
|
|
|
|
--links \
|
|
|
|
--links \
|
|
|
|
@@ -91,7 +90,7 @@ syncFromDisk () {
|
|
|
|
${XTRA_RSYNC_FROM[@]+"${XTRA_RSYNC_FROM[@]}"} \
|
|
|
|
${XTRA_RSYNC_FROM[@]+"${XTRA_RSYNC_FROM[@]}"} \
|
|
|
|
$HDD_LOG/ $RAM_LOG/ 2>&1 | $LOG_OUTPUT
|
|
|
|
$HDD_LOG/ $RAM_LOG/ 2>&1 | $LOG_OUTPUT
|
|
|
|
else
|
|
|
|
else
|
|
|
|
${NoCache} find $HDD_LOG/* -maxdepth 1 -type f -not \( -name '*.[0-9]' -or -name '*.xz*' -or -name '*.gz' -or -name 'journal*' \) | xargs cp -ut $RAM_LOG/
|
|
|
|
find $HDD_LOG/* -maxdepth 1 -type f -not \( -name '*.[0-9]' -or -name '*.xz*' -or -name '*.gz' -or -name 'journal*' \) | xargs cp -ut $RAM_LOG/
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
if [ ! -L $RAM_LOG/journal ] && [ -d $HDD_LOG/journal ]; then # link persistent journal if applicable
|
|
|
|
if [ ! -L $RAM_LOG/journal ] && [ -d $HDD_LOG/journal ]; then # link persistent journal if applicable
|
|
|
|
|