Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions engine/src/main/grammar/SQLGrammar.jjt
Original file line number Diff line number Diff line change
Expand Up @@ -4189,6 +4189,14 @@ BackupDatabaseStatement BackupDatabaseStatement():
{ }
{
<BACKUP> <DATABASE> [ jjtThis.url = Url() ]
[
<WITH>
jjtThis.key = Expression() <EQ> jjtThis.value = Expression() { jjtThis.settings.put( jjtThis.key, jjtThis.value ); }
(
<COMMA>
jjtThis.key = Expression() <EQ> jjtThis.value = Expression() { jjtThis.settings.put( jjtThis.key, jjtThis.value ); }
)*
]
{return jjtThis; }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,24 @@

import com.arcadedb.GlobalConfiguration;
import com.arcadedb.database.Database;
import com.arcadedb.database.Identifiable;
import com.arcadedb.exception.CommandExecutionException;
import com.arcadedb.log.LogManager;
import com.arcadedb.query.sql.executor.CommandContext;
import com.arcadedb.query.sql.executor.InternalResultSet;
import com.arcadedb.query.sql.executor.ResultInternal;
import com.arcadedb.query.sql.executor.ResultSet;

import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.util.Map;
import java.util.logging.Level;
import java.io.*;
import java.lang.reflect.*;
import java.util.*;
import java.util.logging.*;

public class BackupDatabaseStatement extends SimpleExecStatement {
protected Url url;
protected Url url;
protected Expression key;
protected Expression value;
protected final Map<Expression, Expression> settings = new HashMap<>();

public BackupDatabaseStatement(final int id) {
super(id);
Expand Down Expand Up @@ -67,8 +71,21 @@ public ResultSet executeSimple(final CommandContext context) {

clazz.getMethod("setDirectory", String.class).invoke(backup, backupDirectory + context.getDatabase().getName());
clazz.getMethod("setVerboseLevel", Integer.TYPE).invoke(backup, 0);
try {

if (!settings.isEmpty()) {
for (Map.Entry<Expression, Expression> entry : settings.entrySet()) {
final String stringValue = entry.getValue().execute((Identifiable) null, context).toString();

switch (entry.getKey().toString()) {
case "encryptionAlgorithm" -> clazz.getMethod("setEncryptionAlgorithm", String.class)
.invoke(backup, stringValue);
case "encryptionKey" -> clazz.getMethod("setEncryptionKey", String.class)
.invoke(backup, stringValue);
}
}
}

try {
final String backupFile = (String) clazz.getMethod("backupDatabase").invoke(backup);
result.setProperty("result", "OK");
result.setProperty("backupFile", backupFile);
Expand Down
Loading
Loading