-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* some helpful scripts for production deployments * rsync cron * change sync to every minute
- Loading branch information
Showing
5 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/bin/bash | ||
# a script to compress enclave extrinsic logs in the working dir for the previous day and delete them to clean up | ||
# run as root with crontab | ||
# crontab -e | ||
# 0 2 * * * /path/to/your_script.sh /abs-path-to-log-directory | ||
|
||
# Check if a directory argument was provided, default to current directory if not | ||
DIRECTORY="${1:-.}" | ||
# Remove any trailing slash from the directory path | ||
DIRECTORY="${DIRECTORY%/}" | ||
|
||
# Define the archive file name with yesterday's date | ||
ARCHIVE_NAME="archive_$(date -d 'yesterday' +%Y%m%d).tar.gz" | ||
# Define the date string for yesterday | ||
YESTERDAY_DATE=$(date -d 'yesterday' +%Y%m%d) | ||
|
||
# Find and archive all files in the directory created yesterday | ||
#FILES_TO_ARCHIVE=$(find "$DIRECTORY" -type f -newermt "yesterday 00:00:00" ! -newermt "today 00:00:00") | ||
# Find all files in the directory matching yesterday's date in the filename | ||
FILES_TO_ARCHIVE=$(find "$DIRECTORY" -type f -name "extrinsics-$YESTERDAY_DATE-*") | ||
|
||
# Check if there are any files to archive | ||
if [ -z "$FILES_TO_ARCHIVE" ]; then | ||
echo "No files created yesterday in $DIRECTORY." | ||
exit 0 | ||
fi | ||
|
||
# Create the archive with the files found | ||
tar -czf "$DIRECTORY/$ARCHIVE_NAME" $FILES_TO_ARCHIVE | ||
|
||
# Check if the tar command was successful | ||
if [ $? -eq 0 ]; then | ||
# If successful, delete the original files | ||
echo "Archive created successfully as $ARCHIVE_NAME. Deleting original files." | ||
rm -f $FILES_TO_ARCHIVE | ||
else | ||
echo "Failed to create archive. Original files are not deleted." | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# as root, execute | ||
# crontab -e | ||
# and make the following entries: | ||
|
||
# daily @2:00am, archive logs and clean up | ||
0 2 * * * /opt/sidechain-paseo/archive-yesterdays-logs.sh /opt/sidechain-paseo/log-extrinsics-to-Integritee | ||
0 2 * * * /opt/sidechain-paseo/archive-yesterdays-logs.sh /opt/sidechain-paseo/log-extrinsics-to-TargetA | ||
|
||
# daily @1:00am, snapshot light client dB's (syncing is fast enough for 24h intervals) | ||
0 1 * * * /opt/sidechain-paseo/snapshot-integritee-db.sh /opt/sidechain-paseo | ||
0 1 * * * /opt/sidechain-paseo/snapshot-target-a-db.sh /opt/sidechain-paseo | ||
|
||
# hourly, take shard snapshot | ||
0 * * * * /opt/sidechain-paseo/snapshot-shards.sh /opt/sidechain-paseo | ||
|
||
# every minute, rsync to peer node which might be able to hot-swap in emergencies. execute as user, not root | ||
* * * * * su - ubuntu -c "rsync -avz --delete /opt/sidechain-paseo/ ubuntu@integritee-2:/opt/mirror-integritee-1/sidechain-paseo/" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
# Check if a directory argument was provided, default to current directory if not | ||
DIRECTORY="${1:-.}" | ||
# Remove any trailing slash from the directory path | ||
DIRECTORY="${DIRECTORY%/}" | ||
|
||
timestamp=$(date +%Y%m%d-%T) | ||
echo "snappshotting all light client db's at $timestamp" | ||
cp -r "$DIRECTORY/integritee_lcdb" "$DIRECTORY/integritee_lcdb_$timestamp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash | ||
# Check if a directory argument was provided, default to current directory if not | ||
DIRECTORY="${1:-.}" | ||
# Remove any trailing slash from the directory path | ||
DIRECTORY="${DIRECTORY%/}" | ||
|
||
timestamp=$(date +%Y%m%d-%T) | ||
echo "snappshotting all shards at $timestamp" | ||
cp -r "$DIRECTORY/shards" "$DIRECTORY/shards_$timestamp" | ||
cp -r "$DIRECTORY/sidechain_db" "$DIRECTORY/sidechain_db_$timestamp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
# Check if a directory argument was provided, default to current directory if not | ||
DIRECTORY="${1:-.}" | ||
# Remove any trailing slash from the directory path | ||
DIRECTORY="${DIRECTORY%/}" | ||
|
||
timestamp=$(date +%Y%m%d-%T) | ||
echo "snappshotting all light client db's at $timestamp" | ||
cp -r "$DIRECTORY/target_a_lcdb" "$DIRECTORY/target_a_lcdb_$timestamp" |