Let's start from afar, since, according to the condition of the problem, SNB cannot be used :-)
It's necessary to start with the fact that backups are divided into two types, physical and logical.
Physical
This is copying data from database files to a backup file without significant transformations. For SQL Server, this is the BACKUP DATABASE
command - the DBMS performs a low-level paging copy from the database file to the backup file.
For a "Physical backup", a file is created and filled by the DBMS itself. A backup can be performed to a storage to which a DBMS has file access.
Physical backups, as a rule, are created much faster and restored much faster. In addition, SQL Server physical backups support incremental backups (Transaction Log, Differential).
Logical
This is a copy of the logical representation of the database data (what we see in SQL Server Management Studio). During a logical backup, backuptool essentially performs a lot of SELECT
queries on system and non-system tables to understand what the database consists of, and then writes it to the backup file. For SQL Server, a logical backup is usually created in the form of a .bacpac
file, or as a T-SQL script containing instructions for creating a database.
For a logical backup, a file is created and populated by backuptool. Where you run it, there a backup will be created
Logical backups, on the contrary, take a long time to create, load the database very heavily all this time - and take a very long time to restore. In addition, to ensure the transactional consistency of a logical backup in SQL Server, you first need to take a snapshot of the database, and make a backup of the snapshot, and not the database itself.
In most situations, it's recommended to perform a physical backup
BACKUP DATABASE [AdventureWorks] TO DISK = ...
A backup file transfer to another server is a separate issue. If it is not possible to do this via SMB, then you can transfer the file via FTP - or Google Drive.
By the way, there is a command line utility SqlBak-CLI that can do both backup and restore the database on FTP.
For a small database, a logical backup can be done remotely, the main thing is that the user under which the connection to the database is set has enough read privileges.
Microsoft provides two command line tools to create a logical backup:
- MSSQL-Scripter - creates
.sql
which will create the tables and fill them with data as in the original database. Usage example:
# set environment variable MSSQL_SCRIPTER_PASSWORD so no password input is required.
mssql-scripter -S 192.168.3.4 -d AdventureWorks -U sa -f ./adventureworks.sql
- sqlpackage.exe - exports the database to a
.bacpac
file. In fact, this file is an archive in which a description of the tables and what they contain are stored in XML format.
SqlPackage.exe /Action:Export /TargetFile:"C:\AdventureWorkss.bacpac" \ /SourceConnectionString:"Server=tcp:192.168.3.4,1433;Initial Catalog=AdventureWorks;User ID=sqladmin;Password={your_password};"