}
@Override
public <Z, D extends Database<Z>> void restore(D database, Decoder decoder, File file, boolean dataOnly) throws Exception
{
ConnectionProperties properties = this.getConnectionProperties(database, decoder);
ProcessBuilder builder = new ProcessBuilder("pg_restore");
List<String> args = builder.command();
args.add("--host=" + properties.getHost());
args.add("--port=" + properties.getPort());
args.add("--username=" + properties.getUser());
args.add("--no-password");
args.add("--dbname=" + properties.getDatabase());
args.add("--clean");
if (dataOnly)
{
args.add("--data-only");
args.add("--disable-triggers"); // Used to prevent integrity constraints during restoration of data
args.add("--superuser=" + properties.getUser()); // Required by --disable-triggers
}
args.add(file.getPath());
Processes.run(setPassword(builder, properties));
}