When the target for backupwallet is the source wallet file or directory, the wallet file is cleared to zero length

### Reproduce
bitcoin-cli backupwallet ~/.bitcoin/

### Expected behaviour
Command should fail

### Actual behaviour
Wallet is destroyed.

Reported here
https://www.reddit.com/r/btc/comments/719kz3/just_lost_4bch_backing_up_my_walletdat_file/

Fix proposed in #11376 
{
    dbenv->txn_checkpoint(0, 0, 0);
    if (fMockDb)
        return;
    dbenv->lsn_reset(strFile.c_str(), 0);
}
CDB::CDB(CWalletDBWrapper& dbw, const char* pszMode, bool fFlushOnCloseIn) : pdb(nullptr), activeTxn(nullptr)
{
    fReadOnly = (!strchr(pszMode, '+') && !strchr(pszMode, 'w'));
    fFlushOnClose = fFlushOnCloseIn;
    env = dbw.env;
    if (dbw.IsDummy()) {
        return;
    }
    const std::string &strFilename = dbw.strFile;
    bool fCreate = strchr(pszMode, 'c') != nullptr;
    unsigned int nFlags = DB_THREAD;
    if (fCreate)
        nFlags |= DB_CREATE;
    {
        LOCK(env->cs_db);
        if (!env->Open(GetDataDir()))
            throw std::runtime_error("CDB: Failed to open database environment.");
        strFile = strFilename;
        ++env->mapFileUseCount[strFile];
        pdb = env->mapDb[strFile];
        if (pdb == nullptr) {
            int ret;
            pdb = new Db(env->dbenv, 0);
            bool fMockDb = env->IsMock();