import { DatabaseIcon, InfoIcon, TriangleAlertIcon } from "lucide-react"; import React, { useState } from "react"; import { useNavigate } from "react-router"; import PasswordInput from "src/components/password/PasswordInput"; import SettingsHeader from "src/components/SettingsHeader"; import { Button } from "src/components/ui/button"; import { LinkButton } from "src/components/ui/custom/link-button"; import { LoadingButton } from "src/components/ui/custom/loading-button"; import { Label } from "src/components/ui/label"; import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, } from "src/components/ui/tooltip"; import { useInfo } from "src/hooks/useInfo"; import { handleRequestError } from "src/utils/handleRequestError"; import { isHttpMode } from "src/utils/isHttpMode"; import { request } from "src/utils/request"; export function MigrateNode() { const navigate = useNavigate(); const { data: info } = useInfo(); const [unlockPassword, setUnlockPassword] = React.useState(""); const [showPasswordScreen, setShowPasswordScreen] = useState(false); const [loading, setLoading] = React.useState(false); const onSubmitPassword = async (e: React.FormEvent) => { e.preventDefault(); const _isHttpMode = isHttpMode(); try { setLoading(true); if (_isHttpMode) { const response = await fetch("/api/backup", { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ UnlockPassword: unlockPassword, }), }); if (!response.ok) { throw new Error(await response.text()); } const blob = await response.blob(); const url = window.URL.createObjectURL(blob); const a = document.createElement("a"); a.href = url; a.download = "albyhub.bkp"; document.body.appendChild(a); a.click(); window.URL.revokeObjectURL(url); a.remove(); } else { await request("/api/backup", { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ unlockPassword, }), }); } navigate("/create-node-migration-file-success"); } catch (error) { handleRequestError("Failed to backup the node", error); } finally { setLoading(false); } }; return ( <>

Do not run your Alby Hub on multiple devices

After creating this migration file, do not restart Alby Hub on this device, as this will cause problems and may cause force channel closures.

Migrate this file only to fresh Alby Hub

To import the migration file, you must have a brand new Alby Hub on another device and use the “Advanced” option during the onboarding.

Never share your migration file

Anyone with this file and your unlock password can access your funds. Never send it to anyone. Alby support will never ask for it.

What happens next?

After typing your unlock password, you'll be able to download a migration file which contains a backup of your Alby Hub data. Then you'll see instructions on how to import this migration file into another device or server.

{info?.databaseType === "postgres" && (

Your database will be migrated

The contents of your PostgreSQL database will be copied into a local SQLite database while the migration file is being created. Your new Alby Hub will use this SQLite database.
)}
{showPasswordScreen ? (

Enter unlock password

Your unlock password will be used to encrypt your migration file

<>
Continue
) : (
Backup Without Migrating Alby Hub
)} ); }