15 lines
597 B
Bash
15 lines
597 B
Bash
#!/bin/sh
|
|
# Shell script to be run as cron job to copy npm logs to backup location.
|
|
|
|
# Stop npm service to ensure logs are not being written to while copying.
|
|
systemctl stop npm
|
|
|
|
# Only copy new/changed log files to avoid re-copying existing backups.
|
|
# --ignore-existing: never overwrite files already present in the destination.
|
|
# -c: compare files by checksum so matching files are not re-written.
|
|
# -P: preserve permissions + show progress.
|
|
rsync -qcP --ignore-existing /data/logs/*access* /data/logs/*error* /mnt/backups/npm/
|
|
|
|
# Start npm service again after copying logs.
|
|
systemctl start npm
|