Initiate a database backup, SQLite 3.x only.

@param dest destination database
@param destName schema of destination database to be backed up
@param srcName schema of source database
@return Backup object to perform the backup operation
519591
public Backup backup( Database dest, String destName, String srcName ) throws jsqlite.Exception {
        synchronized (this) {
            Backup b = new Backup();
            _backup(b, dest, destName, this, srcName);
            return b;
        }
    }
1358099
function OriginDB(name, options) {
  let objects = {};
  let checksums = {};

  if (!_.isString(name)) {
    throw new Error('Invalid name');
  }

  if (_.isObject(options)) {
    options = Object.assign({}, defaultOptions, options);
  } else {
    options = defaultOptions;
  }

  if (_.isString(options.adapter) && !_.has(adapters, options.adapter)) {
    throw new Error('Unknown adapter');
  }

  const save = _.isFunction(options.adapter) ?
    options.adapter(name, objects, checksums, options) :
    adapters[options.adapter](name, objects, checksums, options);

  /**
   * The database instance.
   *
   * @param {string} objectName
   * @param {Object} methods
   */
  function db(objectName) {
    if (_.isBoolean(save.hasLoaded)) deasync.loopWhile(() => !save.hasLoaded);
    if (!_.has(objects, objectName)) objects[objectName] = {};
    return createMethods(objects[objectName], save.bind(null, objectName));
  }

  // backwards compatability with < v2.4.1
  db.save = () => {
    if (_.isBoolean(save.hasLoaded)) deasync.loopWhile(() => !save.hasLoaded);
    _.forIn(objects, function(value, file) {
      save(file);
    });
  };

  return db;
}
596304
public synchronized OServerAdmin createDatabase(final String iDatabaseType, String iStorageMode) throws IOException {
    storage.checkConnection();

    try {
      if (storage.getName() == null || storage.getName().length() <= 0) {
        OLogManager.instance().error(this, "Cannot create unnamed remote storage. Check your syntax", OStorageException.class);
      } else {
        if (iStorageMode == null)
          iStorageMode = "csv";

        final OChannelBinaryClient network = storage.beginRequest(OChannelBinaryProtocol.REQUEST_DB_CREATE);
        try {
          network.writeString(storage.getName());
          if (network.getSrvProtocolVersion() >= 8)
            network.writeString(iDatabaseType);
          network.writeString(iStorageMode);
        } finally {
          storage.endRequest(network);
        }

        storage.getResponse(network);

      }

    } catch (Exception e) {
      OLogManager.instance().error(this, "Cannot create the remote storage: " + storage.getName(), e, OStorageException.class);
      storage.close(true);
    }
    return this;
  }
116029
@InterfaceAudience.Private
    private void replaceDatabase(String databaseName,
                                 InputStream databaseStream,
                                 Iterator<Map.Entry<String, InputStream>> attachmentStreams)
            throws CouchbaseLiteException {
        try {
            Database db = getDatabase(databaseName, false);

            String dstDbPath = FileDirUtils.getPathWithoutExt(db.getPath()) + kV1DBExtension;
            String dstAttsPath = FileDirUtils.getPathWithoutExt(dstDbPath) + " attachments";

            OutputStream destStream = new FileOutputStream(new File(dstDbPath));
            StreamUtils.copyStream(databaseStream, destStream);
            File attachmentsFile = new File(dstAttsPath);
            FileDirUtils.deleteRecursive(attachmentsFile);
            if (!attachmentsFile.exists()) {
                attachmentsFile.mkdirs();
            }
            if (attachmentStreams != null) {
                StreamUtils.copyStreamsToFolder(attachmentStreams, attachmentsFile);
            }
            if (!upgradeV1Database(databaseName, dstDbPath)) {
                throw new CouchbaseLiteException(Status.INTERNAL_SERVER_ERROR);
            }
            db.open();
            db.replaceUUIDs();
        } catch (FileNotFoundException e) {
            Log.e(Database.TAG, "Error replacing the database: %s", e, databaseName);
            throw new CouchbaseLiteException(Status.INTERNAL_SERVER_ERROR);
        } catch (IOException e) {
            Log.e(Database.TAG, "Error replacing the database: %s", e, databaseName);
            throw new CouchbaseLiteException(Status.INTERNAL_SERVER_ERROR);
        }
    }
798731
def init_db(self):
        

        # database file
        db_path = self.get_data_file("data.sqlite")

        # comect and create cursor
        self.db = sqlite3.connect(db_path)
        self.cursor = self.db.cursor()

        # prep tables
        self.db_exec('''
            CREATE TABLE IF NOT EXISTS shortcuts (
                id INTEGER PRIMARY KEY AUTOINCREMENT,
                name TEXT NOT NULL,
                path TEXT NOT NULL,
                command TEXT NOT NULL
            )
            ''')
336850
public void toWEBP(String src, String dest) {
        toWEBP(new File(src), new File(dest));
    }
1050333
function createTable (db, name) {
  return r.db(db).tableCreate(name).run().then(function () {
    console.log('RETHINKDB: Created Table', name, 'on', db)
  }).catch(function (err) {
    console.log('RETHINKDB: Table', name, 'on', db, 'exists')
  })
}
1128024
def makeBackupFile(self, dstPath, fileName):
        

        with open(os.devnull) as devnull:
            SP.call(['mongodump', '--db', self.dbName, '--out', dstPath],
                    stdout=devnull,
                    stderr=devnull)
            SP.call(['zip',
                     '-r',
                     os.path.join(dstPath, fileName),
                     os.path.join(dstPath, self.dbName)],
                    stdout=devnull,
                    stderr=devnull)

        SP.call(['rm', '-rf', os.path.join(dstPath, self.dbName)])
947742
public boolean create(String strDatabaseName) throws DBException
    {
        try {
            String strDBName = this.getProperty(SQLParams.INTERNAL_DB_NAME);
            int iDatabaseType = DBConstants.SYSTEM_DATABASE;
            DatabaseOwner env = this.getDatabaseOwner();
            JdbcDatabase db = (JdbcDatabase)env.getDatabase(strDBName, iDatabaseType, null);    // Do NOT pass properties when opening system database
            Statement queryStatement = db.getJDBCConnection().createStatement();

            String strSQL = "create database " + strDatabaseName + ";";
            queryStatement.execute(strSQL);
            queryStatement.close();
            db.free();

            String oldValue = this.getProperty(DBConstants.CREATE_DB_IF_NOT_FOUND);
            this.setProperty(DBConstants.CREATE_DB_IF_NOT_FOUND, DBConstants.FALSE);
            
            this.close();   // Since I don't know what kind of connection this is.
            this.setupDBConnection();

            this.setProperty(DBConstants.CREATE_DB_IF_NOT_FOUND, oldValue);
            
            if (this.getProperty(DBConstants.LOAD_INITIAL_DATA) != null)
            	if ((this.getDatabaseType() & (DBConstants.SHARED_DATA | DBConstants.USER_DATA)) == DBConstants.SHARED_DATA)	// Yes, only shared data can have DatabaseInfo
            {
                DatabaseInfo recDatabaseInfo = new DatabaseInfo();
                try {
                	recDatabaseInfo.setDatabaseName(this.getDatabaseName(false));
                	recDatabaseInfo.setTable(this.doMakeTable(recDatabaseInfo));    // This makes a jdbc table
                	recDatabaseInfo.init(null); // This should create the table if an archive exists
                } catch (Exception ex) {
                	// Ignore
                } finally {
                	recDatabaseInfo.free();
                }
            }
            return true;    // Success
        } catch (SQLException ex) {
            ex.printStackTrace();
        }

        return super.create(strDatabaseName);   // Error, not found
    }
943667
@Override
	public JdbcDatabaseDescriptor dbByName(final String dbName) {
		Collection<H2DatabaseWorking> select = CollectionUtils.select(dbsw, new Predicate<H2DatabaseWorking>() {

			@Override
			public boolean evaluate(H2DatabaseWorking db) {
				return dbName.equals( db.getName() );
			}

		});
		if(CollectionUtils.size(select)==0){
			throw new IllegalArgumentException("There are no databases called '" + dbName + "'");
		}
		if(CollectionUtils.size(select)>=2){
			throw new IllegalArgumentException("More than one database is called '" + dbName + "'");
		}
		return CollectionUtils.extractSingleton( select );
	}
368061
@Override
    protected File cloneRepository(File dest) {
        // build url
        String url = getUrl();
        String branch = getBranch();
        String tag = getTag();
        StringBuilder urlBuilder = new StringBuilder();
        urlBuilder.append(url);
        if (StringUtils.isNotBlank(branch)) {
            if (branch.equalsIgnoreCase(TRUNK)) {
                if (!url.endsWith(TRUNK)) {
                    urlBuilder.append(URL_TRUNK);
                }
            } else {
                urlBuilder.append(URL_BRANCHES);
                urlBuilder.append(branch);
            }
        } else if (StringUtils.isNotBlank(tag)) {
            urlBuilder.append(URL_TAGS);
            urlBuilder.append(tag);
        }

        // setup svn client
        SVNClientManager clientManager = SVNClientManager.newInstance(SVNWCUtil.createDefaultOptions(true), getUsername(), getPassword());
        SVNUpdateClient updateClient = clientManager.getUpdateClient();
        updateClient.setIgnoreExternals(false);

        final SvnOperationFactory svnOperationFactory = new SvnOperationFactory();
        try {
            final SvnCheckout checkout = svnOperationFactory.createCheckout();
            checkout.setSingleTarget(SvnTarget.fromFile(dest));
            checkout.setSource(SvnTarget.fromURL(SVNURL.parseURIEncoded(urlBuilder.toString())));
            checkout.setRevision(SVNRevision.HEAD);
            checkout.run();
        } catch (SVNException e) {
            logger.error("error during checkout: {}", e.getMessage());
        } finally {
            svnOperationFactory.dispose();
        }

        return dest;
    }
1367385
public static BufferedImage copy(BufferedImage src, BufferedImage dest) {
        dest.getGraphics().drawImage(src, 0, 0, null);
        return dest;
    }
649445
def _sincedb_init(self):
        """"""
        if not self._sincedb_path:
            return

        if not os.path.exists(self._sincedb_path):
            self._log_debug('initializing sincedb sqlite schema')
            conn = sqlite3.connect(self._sincedb_path, isolation_level=None)
            conn.execute("""
            create table sincedb (
                fid      text primary key,
                filename text,
                position integer default 1
            );
            """)
            conn.close()
1059673
@Override
    protected File cloneRepository(File dest) {
        Git git = null;
        try {
            // set branch name
            String branchName = MASTER;;
            String branch = getBranch();
            if (StringUtils.isNotBlank(branch)) {
                branchName = branch;
            }
            String tag = getTag();
            if (StringUtils.isNotBlank(tag)) {
                branchName = tag;
            }

            CloneCommand cloneCommand = Git.cloneRepository();

            // use private key if available
            final String privateKey = getPrivateKey();
            if (StringUtils.isNotBlank(privateKey)) {
                final SshSessionFactory sshSessionFactory = new JschConfigSessionFactory() {
                    @Override
                    protected void configure(OpenSshConfig.Host host, Session session) {
                        // set password if available
                        String password = getPassword();
                        if (StringUtils.isNotBlank(password)) {
                            session.setPassword(password);
                        }
                    }

                    @Override
                    protected JSch createDefaultJSch(FS fs) throws JSchException {
                        JSch defaultJSch = super.createDefaultJSch(fs);
                        defaultJSch.addIdentity(privateKey);
                        return defaultJSch;
                    }
                };
                cloneCommand.setTransportConfigCallback(new TransportConfigCallback() {
                    @Override
                    public void configure(Transport transport) {
                        if( transport instanceof SshTransport ) {
                            SshTransport sshTransport = (SshTransport) transport;
                            sshTransport.setSshSessionFactory(sshSessionFactory);
                        } else {
                            logger.warn("you are not using ssh protocol while using scm.ppk");
                        }
                    }
                });
                cloneCommand.setCredentialsProvider(new passphraseCredentialsProvider(getPassword()));
            } else {
                if (getUrlName() != null && getPassword() != null) {
                    cloneCommand.setCredentialsProvider(new UsernamePasswordCredentialsProvider(getUsername(), getPassword()));
                }
            }

            // clone repository
            git = cloneCommand.setURI(getUrl())
                    .setBranch(branchName)
                    .setDirectory(dest)
                    .call();
        } catch (InvalidPathException e) {
            logger.warn("Error cloning git repository: {}", e.getMessage());
        } catch (GitAPIException e) {
            logger.warn("Error processing git repository: {}", e.getMessage());
        } finally {
            if (git != null) {
                git.close();
            }
        }
        return dest;
    }
113768
public void addTable(TableKelp tableKelp,
                       String sql,
                       BackupKelp backupCb)
  {
    // TableKelp tableKelp = tableKraken.getTableKelp();
   
    RowCursor cursor = _metaTable.cursor();
    
    cursor.setBytes(1, tableKelp.tableKey(), 0);
    cursor.setString(2, tableKelp.getName());
    cursor.setString(3, sql);

    //BackupCallback backupCb = _metaTable.getBackupCallback();
    
    //_metaTable.getTableKelp().put(cursor, backupCb, 
    //                              new CreateTableCompletion(tableKraken, result));
    
    // _metaTable.getTableKelp().put(cursor, backupCb, 
    //                               result.from(v->tableKraken));
    
    _metaTable.put(cursor, backupCb, Result.ignore());
    
    // tableKraken.start();
  }
1174027
function(dest, source) {

		var name;

		for (name in source) {

			if (!(name in dest)) {

				dest[name] = source[name];

			} else {

				if (Lava.schema.DEBUG && (dest[name].type != source[name].type || dest[name].tag_name != source[name].tag_name)) Lava.t("[Config storage_schema] property types must match: " + name);

				if ('properties' in source[name]) {

					if (!('properties' in dest[name])) {

						dest[name].properties = source[name].properties;

					} else {

						Firestorm.implement(dest[name].properties, source[name].properties);

					}

				}

			}

		}

	}
1277775
public static Object copy(Object src, Object dest, int length) {
		System.arraycopy(src, 0, dest, 0, length);
		return dest;
	}