Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Tweak db-export parallel command

Leendert de Borst8d0042758f8f
diff --git a/apps/server/AliasVault.Api/Controllers/VaultController.cs b/apps/server/AliasVault.Api/Controllers/VaultController.cs
index 503697368..22809505a 100644
--- a/apps/server/AliasVault.Api/Controllers/VaultController.cs
+++ b/apps/server/AliasVault.Api/Controllers/VaultController.cs
@@ -376,10 +376,13 @@ public class VaultController(ILogger<VaultController> logger, IAliasServerDbCont
var supportedPrivateDomains = config.PrivateEmailDomains;
// Determine the new-account alias creation limit (abuse mitigation). When enabled, accounts younger than
- // NewAccountAliasLimitDays may not have more than MaxAliasesForNewAccounts active aliases. Both 0 = disabled.
+ // NewAccountAliasLimitDays may not create more than MaxAliasesForNewAccounts aliases in total. We count every
+ // alias the account has ever claimed (including disabled ones), because abusers spin up many throw-away aliases
+ // and disable them after a single use; only counting active aliases would let them bypass the cap entirely.
+ // Both 0 = disabled.
var settings = await settingsService.GetAllSettingsAsync();
var aliasLimitActive = settings.NewAccountAliasLimitDays > 0 && settings.MaxAliasesForNewAccounts > 0 && user.CreatedAt > timeProvider.UtcNow.AddDays(-settings.NewAccountAliasLimitDays);
- var activeAliasCount = userOwnedEmailClaims.Count(x => !x.Disabled);
+ var ownedAliasCount = userOwnedEmailClaims.Count;
var aliasLimitLogged = false;
// Register new email addresses.
@@ -432,7 +435,7 @@ public class VaultController(ILogger<VaultController> logger, IAliasServerDbCont
// Enforce the new-account alias creation limit: once the account is at its cap, silently skip creating
// additional aliases (logged once so the limit being hit is visible for audits).
- if (aliasLimitActive && activeAliasCount >= settings.MaxAliasesForNewAccounts)
+ if (aliasLimitActive && ownedAliasCount >= settings.MaxAliasesForNewAccounts)
{
if (!aliasLimitLogged)
{
@@ -455,7 +458,7 @@ public class VaultController(ILogger<VaultController> logger, IAliasServerDbCont
CreatedAt = timeProvider.UtcNow,
UpdatedAt = timeProvider.UtcNow,
});
- activeAliasCount++;
+ ownedAliasCount++;
}
catch (DbUpdateException ex)
{
diff --git a/install.sh b/install.sh
index 440507676..d366388ce 100755
--- a/install.sh
+++ b/install.sh
@@ -3025,19 +3025,23 @@ handle_db_export() {
export_start_time=$(date +%s)
if [ "$PARALLEL_JOBS" -gt 0 ]; then
- # Use pigz for parallel compression
- # Use nice (lowest CPU priority) and ionice (lowest I/O priority) to minimize impact
+ # pigz for parallel compression, at lowest CPU/IO priority..
printf "${CYAN}> Exporting ${DB_TYPE} database with parallel=${PARALLEL_JOBS} compression...${NC}\n" >&2
- $DOCKER_CMD bash -c "
- ionice -c 3 nice -n 19 pg_dump -U aliasvault aliasvault | ionice -c 3 nice -n 19 pigz -1 -p ${PARALLEL_JOBS} 2>/dev/null || \
- nice -n 19 pg_dump -U aliasvault aliasvault | nice -n 19 pigz -1 -p ${PARALLEL_JOBS}
- " 2>/dev/null
+ if $DOCKER_CMD sh -c 'command -v ionice' >/dev/null 2>&1; then
+ IO_PREFIX="ionice -c 3 "
+ else
+ IO_PREFIX=""
+ fi
+ $DOCKER_CMD bash -c "set -o pipefail; ${IO_PREFIX}nice -n 19 pg_dump -U aliasvault aliasvault | ${IO_PREFIX}nice -n 19 pigz -1 -p ${PARALLEL_JOBS}"
+ export_status=$?
else
# Standard gzip
printf "${CYAN}> Exporting ${DB_TYPE} database...${NC}\n" >&2
+ set -o pipefail
$DOCKER_CMD nice -n 19 pg_dump -U aliasvault aliasvault | gzip -1
+ export_status=$?
+ set +o pipefail
fi
- export_status=$?
# End timing
export_end_time=$(date +%s)
@@ -3186,13 +3190,13 @@ handle_db_import() {
progress() { cat; }
fi
- # Reassemble the full stream.
import_start_time=$(date +%s)
set -o pipefail
printf "${CYAN}> Importing data into the database. This can take several minutes for large backups, please wait...${NC}\n"
- # The setup commands MUST read from /dev/null.
+ # Setup commands read /dev/null: docker exec -T would otherwise drain the shared-offset stdin stream.
+ # The pipeline then reassembles the peeked header with the rest of fd 3 and streams it into psql.
if [ "$VERBOSE" = true ]; then
$DOCKER_CMD psql -U aliasvault postgres -c "SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = 'aliasvault' AND pid <> pg_backend_pid();" < /dev/null && \
$DOCKER_CMD psql -U aliasvault postgres -c "DROP DATABASE IF EXISTS aliasvault;" < /dev/null && \