diff --git a/src/lib/components/billing/alerts/backupDatabase.svelte b/src/lib/components/billing/alerts/backupDatabase.svelte
new file mode 100644
index 000000000..4b9c256bb
--- /dev/null
+++ b/src/lib/components/billing/alerts/backupDatabase.svelte
@@ -0,0 +1,28 @@
+
+
+{#if isCloud && $organization?.$id && $page.url.pathname.match(/\/databases\/database-[^/]+$/)}
+
+ {subtitle}
+
+
+
+
+{/if}
diff --git a/src/lib/stores/database.ts b/src/lib/stores/database.ts
new file mode 100644
index 000000000..b4252c5f7
--- /dev/null
+++ b/src/lib/stores/database.ts
@@ -0,0 +1,31 @@
+import { derived } from 'svelte/store';
+import { page } from '$app/stores';
+import { type Models, Query } from '@appwrite.io/console';
+import { sdk } from '$lib/stores/sdk';
+import { headerAlert } from '$lib/stores/headerAlert';
+import BackupDatabase from '$lib/components/billing/alerts/backupDatabase.svelte';
+
+export const database = derived(page, ($page) => $page.data?.database as Models.Database);
+
+export async function checkForDatabaseBackupPolicies(database: Models.Database) {
+ let total = 0;
+ try {
+ const policies = await sdk.forConsole.backups.listPolicies([
+ Query.limit(1),
+ Query.equal('resourceId', database.$id)
+ ]);
+
+ total = policies.total;
+ } catch (e) {
+ // ignore, backups not allowed on free plan error.
+ }
+
+ if (!total) {
+ headerAlert.add({
+ id: 'databasesBackup',
+ component: BackupDatabase,
+ show: true,
+ importance: 7
+ });
+ }
+}
diff --git a/src/lib/stores/sdk.ts b/src/lib/stores/sdk.ts
index 5a00d3eb5..1c2a2c529 100644
--- a/src/lib/stores/sdk.ts
+++ b/src/lib/stores/sdk.ts
@@ -71,6 +71,7 @@ export const sdk = {
client: clientConsole,
account: new Account(clientConsole),
avatars: new Avatars(clientConsole),
+ backups: new Backups(clientConsole),
functions: new Functions(clientConsole),
health: new Health(clientConsole),
locale: new Locale(clientConsole),
diff --git a/src/routes/(console)/+layout.svelte b/src/routes/(console)/+layout.svelte
index d0bb0ba18..79aeca742 100644
--- a/src/routes/(console)/+layout.svelte
+++ b/src/routes/(console)/+layout.svelte
@@ -9,6 +9,7 @@
import { app } from '$lib/stores/app';
import { log } from '$lib/stores/logs';
import { newOrgModal, organization } from '$lib/stores/organization';
+ import { database, checkForDatabaseBackupPolicies } from '$lib/stores/database';
import { wizard } from '$lib/stores/wizard';
import { afterUpdate, onMount } from 'svelte';
import { loading } from '$routes/store';
@@ -265,6 +266,12 @@
}
}
+ database.subscribe(async (database) => {
+ if (!database) return;
+ // the component checks `isCloud` internally.
+ await checkForDatabaseBackupPolicies(database);
+ });
+
organization.subscribe(async (org) => {
if (!org) return;
if (isCloud) {