Storage server¶
Using a storage server as a network drive/folder via NFS on Linux¶
Information
The Network File System (NFS) protocol is an application layer protocol that allows clients to access files on a remote server over a network as if they were local. NFS uses a client-server model where the server exports one or more directories and clients mount them on their file systems. The NFS protocol has features such as ease of configuration, cross-platform, transparent file access, data caching, scalability, fault tolerance and security, which together make it very suitable as a protocol for connecting to storage servers, allowing users from different operating systems to work with data on networked storage easily and efficiently.
To use a storage server as a network drive/folder via NFS on Linux, you need to
-
Install the NFS server. Install the
nfs-kernel-server
andrpcbind
packages: -
Configure directory exports. Specify the shared directories in the
/etc/exports
configuration file:This action allows read and write access to the
/data
directory from the specified subnet. -
Restart the NFS server with the command:
-
Mount the local device:
-
Configure automatic mounting on boot. Add this line to
/etc/fstab
:You can use this command to check space usage:
-
To configure automatic backup using the
rsync
utility, you need to add the appropriate command tocrontab
(cron
settings file): -
To create a backup (dump) of a MySQL database, you can use the
mysqldump
utility:This command saves a full backup of the mydb database to the
dump.sql
file in the/mnt/nfs/dump.sql
path. The-u
parameter specifies the user name to connect to MySQL,-p
prompts for a password. To create backups in automatic mode, you can configure this command to run on a schedule using the cron utility.
Use storage server as network drive/folder using Samba protocol on Windows OS¶
Information
Samba is freely distributed software that allows Linux/Unix and Windows systems to communicate on a network at the file and printer level. Samba implements the SMB/CIFS protocols used for file sharing in Windows. This makes it easy to organise file and printer sharing between Linux and Windows computers.
To use a storage server as a network drive/folder using the Samba protocol in Windows, you need to:
-
Install the
samba
andsmbclient
packages on the storage server: -
Create a folder that will be open for network access, such as
/mnt/share
: -
Add this folder to your samba configuration file:
Add to the end of the configuration file:
-
Restart the Samba service:
-
On your local Windows device, open Explorer and select the Map network drive tab:
-
Enter the path to the storage server and the Share network folder:
You will then be prompted to enter credentials to connect to the server and complete the connection:
If the connection is successful, the network folder will be visible in Explorer under Network locations:
If you are experiencing problems working with a network folder due to a lack of permissions, you should check the permissions for working with the folder. You can do this using any graphical client for the SFTP and SCP protocols, such as WinSCP:
Once the user has been given the necessary rights, the network folder will be writable.
-
To mount the drive, use the command:
-
To unmount:
-
Use the
df
command to monitor the occupied space:
-
To copy data automatically, configure a job in
crontab
: -
To back up a MSSQL database, use the command:
Using the storage server from the terminal using the Rsync and SCP utilities¶
Information
Rsync and SCP are command line utilities in Linux and other Unix-like systems for transferring files over a network. Using Rsync and SCP and other utilities to work with files on a remote storage server from the terminal allows you to perform many tasks:
- Automate file transfer and synchronization between servers
- Backup data on storage;
- Centralize file storage and management;
- Fast and flexible file manipulation without a graphical interface;
- Scripting and batching of various data handling tasks.
Advantages of using Rsync over SCP and FTP:
- Rsync is faster due to incremental file transfer, only changes are transferred;
- Compression support and traffic savings;
- Ability to flexibly configure synchronization parameters;
- Support for resuming interrupted file transfers;
- Remote directory mirroring.
For backup, synchronisation and automation tasks, Rsync is therefore often the optimal solution and is preferred by system administrators. It is a powerful and flexible tool for managing files on remote storage.
Rsync¶
Rsync is a utility for synchronizing files and directories between nodes on a network. Features of Rsync:
- Synchronizes the entire directory structure as well as individual files.
- When resynchronizing, it only transfers changed parts of files.
- Uses the Deflate data compression algorithm and the zlib library.
- Uses channel bandwidth sparingly.
- Replicates file permissions.
- Does not require root privileges to operate.
- Suitable for backup and recovery.
Note
The convention used in this manual is user@storage-server. When working with a remote server, an SSH connection requires a user name, such as root
, and the IP address of the server. Therefore, when entering the commands in the examples below, you must enter your credentials in user@IP-address
format, e.g. [email protected]
. The IP address of the server can be found in the Network tab of Invapi:
How to use Rsync to work with files on a storage server from the Terminal:
Note
In our example, we use the apt
package manager designed for use in Debian/Ubuntu distributions. For Red Hat based distributions, the yum
package manager is used.
-
Install Rsync on the local machine:
-
Connect to the storage server. For SSH connection it is better to configure key authorization. You can use the command to generate an SSH key:
Then copy the key to the storage server:
-
Synchronize directories. For example, to synchronize the
/data
directory with the storage server:Options decryption:
avz
:a
- archive mode. Stores symbolic links, owners, groups, permissions and timestamps;v
- increase verbosity. Displays messages about the file copying process;z
- compress file data during the transfer to reduce traffic;
/data
- local source directory;user@storage-server:/backup/data
- destination folder on the remote server.
This command copies the
/data
directory from the local computer to the remote storage server in archive mode. The process is accompanied by detailed output and the data is compressed into the/backup/data
directory for the user user.Copying is performed over the network with all file attributes intact.
-
For a complete mirroring of a directory, you can use the optional
--delete
option, which is necessary to delete unnecessary files:Options decryption:
avz
:a
- archive mode. Stores symbolic links, owners, groups, permissions and timestamps;v
- increase verbosity. Displays messages about the file copying process;z
- compress file data during the transfer to reduce traffic;
-delete
- deletes files in the destination directory/backup/data
that are not in the source directory/data
;/data
- local source directory;user@storage-server:/backup/data
- destination folder on the remote server.
-
Perform a backup using the
--backup
option:Running this command will save old versions of the modified files. For example
This command creates an archived copy of the
/home/user/documents
directory on the storage server in/backup/documents
. The files are copied in compressed form. The copy will backup existing files with the extension .1.
SCP and FTP: file transfer protocols¶
Several data transfer protocols can be used to work with files on a remote storage server from the terminal.
SCP (Secure Copy)¶
SCP allows encrypted copying of files between hosts. To copy a file to a storage server, use the command:
To download a file from the server:
FTP (File Transfer Protocol)¶
To connect via FTP, use the `ftp' command:
Upload the file to the server:
Download the file:
Using the storage server with SFTP and FTP clients¶
Storage servers are used to store and share data. But to take advantage of their benefits, you need convenient and secure access to the files stored on them.
- SFTP (Secure File Transfer Protocol) and FTP (File Transfer Protocol) are protocols used to transfer files between computers over a network.
- SFTP is an extension of the SSH protocol and provides encrypted and secure file transfer. FTP uses clear text without encryption. SFTP is preferred when confidentiality and data integrity are required.
- SFTP and FTP clients are programs that allow a user to connect to SFTP or FTP servers and manage files on those servers. Popular SFTP clients include FileZilla, WinSCP, CyberDuck. Popular FTP clients: FileZilla, SmartFTP, WinSCP.
Note
The main difference between SFTP and FTP is the use of encryption. SFTP encrypts all connections, ensuring data security. FTP transmits data in clear text, leaving it open to interception and modification. In addition, SFTP uses SSH for authentication, whereas FTP uses separate passwords.
WinSCP¶
To use WinSCP in Windows, you need to:
-
Download and install the WinSCP client on a local Windows device.
-
Launch WinSCP. In the Login window, enter the following details:
- Host name: remote server IP address or domain name;
- Port number: 22;
- User name: server login;
- Password: server password.
-
Press
Loginto connect to the server. -
The left pane contains files on the local device, the right pane contains files on the remote server:
-
To copy a file from the computer to the server - drag it with the mouse from the left pane to the right pane.
-
To transfer files between the server and the local device, simply drag them from one panel to the other.
-
To finish your work, click
Closeor close the program. -
All file copies are encrypted using the SFTP protocol. If you wish, you can select another protocol for the connection.
FileZilla in Linux¶
To use FileZilla on Linux, you need to:
-
Install FileZilla from the repositories of the Linux distribution you are using. For example, in Ubuntu:
-
Launch FileZilla. Enter the details in the Quickconnect bar:
- Host: protocol (SFTP) and IP address or domain of the storage server (e.g.
sftp://31.45.10.34
); - Port: 22;
- Username: server login;
- Password: server password.
- Host: protocol (SFTP) and IP address or domain of the storage server (e.g.
-
Press
Quickconnect. When the connection is successful, the home directory of the local device is displayed on the left. -
To transfer files between the server and the local device, simply drag and drop them from one panel to the other.
-
Press the
Disconnectbutton to exit.