Automatic backup script
The biggest issues for users happen when data files are lost or corrupted, leading to missing or borked trades, or unrecoverable Delayed Payout Transactions.
Having an automated backup solution helps covering that risk, by removing the need to manually run a backup after every application state change (mainly "offer created", "trade started", "trade completed").
Issues could still happen when a critical event occurs right after a state change was saved to disk, but before an automated backup was taken, even if that still significantly limits the probability of a failure to a restricted time window.
Bisq1
Linux
This script requires p7zip-full to be installed, use sudo apt install p7zip-full in debian derivatives if needed.
Create a scripts folder in your home directory, prepare an executable file and open it with an editor:
cd ~ mkdir scripts cd scripts touch bisq1backup chmod +x bisq1backup nano bisq1backup
the following code, that you need to paste in the file and edit where needed, will backup all functional files in the data directory, leaving out non-unique files that the Bisq application will fetch autonomously, and compress them into a 7zip archive, keeping the last N amount of backups that you define (default is 4), while deleting the oldest one if the existing number of backups is higher.
It is advised that you direct the backups to either an external drive, or a NAS, or an encrypted cloud storage.
#!/bin/bash
SOURCE_DIR="/home/YOURUSERNAME/local/share/Bisq/btc_mainnet"
TARGET_FOLDER="/mnt/BACKUPS/BISQ1"
BACKUP_COUNT=4
ARCHIVE_ROOT="bisq1_backup_"
BACKUP_FILE="${ARCHIVE_ROOT}$(date +%Y%m%d_%H%M%S).7z"
ARCHIVE_PATH="${TARGET_FOLDER}/${BACKUP_FILE}"
SELECTED_FILES=(
"BsqSwapTrades"
"BallotList"
"DisputeList"
"RefundDisputeList"
"SequenceNumberMap"
"MyVoteList"
"OpenOffers"
"MyBlindVoteList"
"ClosedTrades"
"MediationDisputeList"
"MyProposalList"
"MailboxMessageList"
"AccountAgeWitnessStore"
"PendingTrades"
"MyProofOfBurnList"
"PreferencesPayload"
"UserPayload"
"AddressEntryList"
"FailedTrades"
"MyReputationList"
"TempProposalStore"
"NavigationPath"
"UnconfirmedBsqChangeOutputList"
"IgnoredMailboxMap"
"PeerList"
"RemovedPayloadsMap"
"TradeStatistics3Store"
"SignedWitnessStore"
)
FOLDER_KEYS="keys"
FOLDER_WALLET="wallet"
FOLDER_TOR="tor/hiddenservice"
FILE_LIST=$(mktemp)
SUBFOLDER_DB_PATH="$SOURCE_DIR/db"
for file in "${SELECTED_FILES[@]}"; do
if [ -f "$SUBFOLDER_DB_PATH/$file" ]; then
echo "$SUBFOLDER_DB_PATH/$file" >> "$FILE_LIST"
fi
done
for subfolder in "$FOLDER_KEYS" "$FOLDER_WALLET"; do
find "$SOURCE_DIR/$subfolder" -maxdepth 1 -type f >> "$FILE_LIST"
done
FOLDER_TOR_PATH="$SOURCE_DIR/$FOLDER_TOR"
if [ -d "$FOLDER_TOR_PATH" ]; then
find "$FOLDER_TOR_PATH" -type f >> "$FILE_LIST"
fi
7z a -t7z -mx=9 -m0=lzma2 -mmt=on -spf "$ARCHIVE_PATH" @"$FILE_LIST"
rm "$FILE_LIST"
echo "Backup completed: $BACKUP_FILE"
ARCHIVE_COUNT=$(find "${TARGET_FOLDER}" -maxdepth 1 -type f -name "${ARCHIVE_ROOT}*.7z" | wc -l)
if [ "${ARCHIVE_COUNT}" -gt "${BACKUP_COUNT}" ]; then
echo "found ${ARCHIVE_COUNT} backups, removing oldest one(s)"
find "${TARGET_FOLDER}" -maxdepth 1 -type f -name "${ARCHIVE_ROOT}*.7z" | sort -r | tail -n +"${BACKUP_COUNT}" | xargs -I {} rm -f {}
fi