statuses_archiver.sh 691 B

12345678910111213141516
  1. #!/bin/sh
  2. mkdir -p "$main_basedir/archives/"
  3. statuses_file_archive_after_time=$(jj -i "$main_basedir"/config.json statuses_file_archive_after_time)
  4. unixtime_offset=$(expr $(date "+%s") - $statuses_file_archive_after_time)
  5. for i in "$main_basedir"/all_statuses/$instance/*; do
  6. old_check=$(date +'%s' -r "$i"/*.json)
  7. if [ $old_check -lt $unixtime_offset ]; then
  8. zip -r -m -u -X "$main_basedir"/archives/$instance.zip $i
  9. echo "[Archiver] Olded status $i $(date -d "@$old_check") moved to archive"
  10. fi
  11. done
  12. find "$main_basedir"/all_statuses/$instance -type d -empty -exec rmdir {} + # Fix not removed empty folder after move (zip bug)