Create backups of wallet.dat automatically
This commit is contained in:
parent
2bb8209877
commit
51304dfaa2
30
src/init.cpp
30
src/init.cpp
@ -711,9 +711,37 @@ bool AppInit2(boost::thread_group& threadGroup)
|
||||
|
||||
int64_t nStart;
|
||||
|
||||
// ********************************************************* Step 5: verify wallet database integrity
|
||||
// ********************************************************* Step 5: Backup wallet and verify wallet database integrity
|
||||
#ifdef ENABLE_WALLET
|
||||
if (!fDisableWallet) {
|
||||
filesystem::path backupDir = GetDataDir() / "backups";
|
||||
if (!filesystem::exists(backupDir))
|
||||
{
|
||||
// Always created backup folder, even when it's not used.
|
||||
filesystem::create_directories(backupDir);
|
||||
}
|
||||
|
||||
if(GetBoolArg("-createwalletbackups", true))
|
||||
{
|
||||
if (!filesystem::exists(backupDir))
|
||||
filesystem::create_directories(backupDir);
|
||||
// Create backup of the wallet
|
||||
if (filesystem::exists(backupDir))
|
||||
{
|
||||
std::string dateTimeStr = DateTimeStrFormat(".%Y-%m-%d %H:%M:%S", GetTime());
|
||||
std::string backupDirStr = backupDir.string();
|
||||
backupDirStr += "/" + strWalletFile;
|
||||
boost::filesystem::path sourceFile = strWalletFile;
|
||||
boost::filesystem::path backupFile = backupDirStr + dateTimeStr;
|
||||
try {
|
||||
boost::filesystem::copy_file(sourceFile, backupFile);
|
||||
LogPrintf("Creating backup of %s -> %s\n", sourceFile, backupFile);
|
||||
} catch(boost::filesystem::filesystem_error &error) {
|
||||
LogPrintf("Failed to create backup %s -> %s\n", sourceFile, backupFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LogPrintf("Using wallet %s\n", strWalletFile);
|
||||
uiInterface.InitMessage(_("Verifying wallet..."));
|
||||
|
||||
|
0
src/init.h
Normal file → Executable file
0
src/init.h
Normal file → Executable file
@ -222,7 +222,8 @@ RES_ICONS = \
|
||||
res/icons/drkblue_editpaste.png \
|
||||
res/icons/drkblue_address-book.png \
|
||||
res/icons/drkblue_editcopy.png \
|
||||
res/icons/drkblue_remove.png
|
||||
res/icons/drkblue_remove.png \
|
||||
res/icons/browse.png
|
||||
|
||||
|
||||
BITCOIN_QT_CPP = \
|
||||
|
@ -193,6 +193,7 @@ BitcoinGUI::BitcoinGUI(bool fIsTestnet, QWidget *parent) :
|
||||
connect(openRPCConsoleAction, SIGNAL(triggered()), rpcConsole, SLOT(showConsole()));
|
||||
connect(openNetworkAction, SIGNAL(triggered()), rpcConsole, SLOT(showNetwork()));
|
||||
connect(openConfEditorAction, SIGNAL(triggered()), rpcConsole, SLOT(showConfEditor()));
|
||||
connect(showBackupsAction, SIGNAL(triggered()), rpcConsole, SLOT(showBackups()));
|
||||
|
||||
|
||||
// prevents an oben debug window from becoming stuck/unusable on client shutdown
|
||||
@ -330,6 +331,8 @@ void BitcoinGUI::createActions(bool fIsTestnet)
|
||||
openNetworkAction->setStatusTip(tr("Show network monitor"));
|
||||
openConfEditorAction = new QAction(QIcon(":/icons/edit"), tr("Open &Configuration File"), this);
|
||||
openConfEditorAction->setStatusTip(tr("Open configuration file"));
|
||||
showBackupsAction = new QAction(QIcon(":/icons/browse"), tr("Show Auto&Backups"), this);
|
||||
showBackupsAction->setStatusTip(tr("S"));
|
||||
|
||||
usedSendingAddressesAction = new QAction(QIcon(":/icons/address-book"), tr("&Sending addresses..."), this);
|
||||
usedSendingAddressesAction->setStatusTip(tr("Show the list of used sending addresses and labels"));
|
||||
@ -408,6 +411,7 @@ void BitcoinGUI::createMenuBar()
|
||||
tools->addAction(openRPCConsoleAction);
|
||||
tools->addAction(openNetworkAction);
|
||||
tools->addAction(openConfEditorAction);
|
||||
tools->addAction(showBackupsAction);
|
||||
}
|
||||
|
||||
QMenu *help = appMenuBar->addMenu(tr("&Help"));
|
||||
@ -570,6 +574,7 @@ void BitcoinGUI::createTrayIconMenu()
|
||||
trayIconMenu->addAction(openRPCConsoleAction);
|
||||
trayIconMenu->addAction(openNetworkAction);
|
||||
trayIconMenu->addAction(openConfEditorAction);
|
||||
trayIconMenu->addAction(showBackupsAction);
|
||||
#ifndef Q_OS_MAC // This is built-in on Mac
|
||||
trayIconMenu->addSeparator();
|
||||
trayIconMenu->addAction(quitAction);
|
||||
|
1
src/qt/bitcoingui.h
Normal file → Executable file
1
src/qt/bitcoingui.h
Normal file → Executable file
@ -97,6 +97,7 @@ private:
|
||||
QAction *openRPCConsoleAction;
|
||||
QAction *openNetworkAction;
|
||||
QAction *openConfEditorAction;
|
||||
QAction *showBackupsAction;
|
||||
QAction *openAction;
|
||||
QAction *showHelpMessageAction;
|
||||
|
||||
|
@ -45,6 +45,7 @@
|
||||
<file alias="drkblue_address-book">res/icons/drkblue_address-book.png</file>
|
||||
<file alias="drkblue_editcopy">res/icons/drkblue_editcopy.png</file>
|
||||
<file alias="drkblue_remove">res/icons/drkblue_remove.png</file>
|
||||
<file alias="browse">res/icons/browse.png</file>
|
||||
</qresource>
|
||||
<qresource prefix="/css">
|
||||
<file alias="drkblue">res/css/drkblue.css</file>
|
||||
|
@ -384,6 +384,15 @@ void openConfigfile()
|
||||
QDesktopServices::openUrl(QUrl::fromLocalFile(boostPathToQString(pathConfig)));
|
||||
}
|
||||
|
||||
void showBackups()
|
||||
{
|
||||
boost::filesystem::path pathBackups = GetDataDir() / "backups";
|
||||
|
||||
/* Open folder with default browser */
|
||||
if (boost::filesystem::exists(pathBackups))
|
||||
QDesktopServices::openUrl(QUrl::fromLocalFile(boostPathToQString(pathBackups)));
|
||||
}
|
||||
|
||||
ToolTipToRichTextFilter::ToolTipToRichTextFilter(int size_threshold, QObject *parent) :
|
||||
QObject(parent), size_threshold(size_threshold)
|
||||
{
|
||||
|
@ -106,6 +106,9 @@ namespace GUIUtil
|
||||
|
||||
// Open dash.conf
|
||||
void openConfigfile();
|
||||
|
||||
// Browse backup folder
|
||||
void showBackups();
|
||||
|
||||
/** Qt event filter that intercepts ToolTipChange events, and replaces the tooltip with a rich text
|
||||
representation if needed. This assures that Qt can word-wrap long tooltip messages.
|
||||
|
BIN
src/qt/res/icons/browse.png
Executable file
BIN
src/qt/res/icons/browse.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 1.7 KiB |
@ -524,3 +524,8 @@ void RPCConsole::showConfEditor()
|
||||
{
|
||||
GUIUtil::openConfigfile();
|
||||
}
|
||||
|
||||
void RPCConsole::showBackups()
|
||||
{
|
||||
GUIUtil::showBackups();
|
||||
}
|
||||
|
2
src/qt/rpcconsole.h
Normal file → Executable file
2
src/qt/rpcconsole.h
Normal file → Executable file
@ -67,6 +67,8 @@ public slots:
|
||||
void showNetwork();
|
||||
/** Open external (default) editor with dash.conf */
|
||||
void showConfEditor();
|
||||
/** Show folder with wallet backups in default browser */
|
||||
void showBackups();
|
||||
|
||||
signals:
|
||||
// For RPC command executor
|
||||
|
Loading…
Reference in New Issue
Block a user