Restoring backup for virtual server with nginx failure

When trying to restore a backup of a virtual top-level server with nginx enabled the following error occurs:

Restoring Nginx webserver configuration ..
Nginx virtualhost was not found after restore!?

When trying to restore a backup of a virtual sub-server with nginx enabled the following error occurs:

Restoring backup for virtual server subdomain.domain.com ..
Restoring Nginx webserver configuration ..
.. no virtual host named subdomain.domain.com exists
.. failed! See the progress output above for the reason why.
Status: 
Closed (fixed)

Comments

Howdy -- are you able to create backups of that particular Virtual Server? Is it just a problem restoring them?

Also, did that problem just begun occurring recently?

Howdy -- are you able to create backups of that particular Virtual Server? Is it just a problem restoring them?

yes, backups are created and the file seems to be correct inside- it contains nginx.conf for a particular domain. This issue occurs from early virtualmin releases with nginx support.

Hmm, well that's unusual! Could you generate a new backup of one of the problem domains, and paste in the output that you receive during that backup? Thanks!

sure, it happens every time with any domain, even with the just created one.

Starting restore of 1 domains from local file /tmp/.webmin/backup (3).tgz ..
Extracting backup archive file ..
.. done
 
Re-creating virtual server example.com ..
Creating administration group wana ..
.. done
Creating administration user wana ..
.. done
 
Creating aliases for administration user ..
.. done
 
Adding administration user to groups ..
.. done
 
Creating home directory ..
.. done
 
Creating mailbox for administration user ..
.. done
 
Adding new DNS zone ..
.. done
 
Adding to email domains list ..
.. done
 
Adding default mail aliases ..
.. done
 
Creating Nginx virtual host ..
.. done
 
Starting PHP FastCGI server ..
.. done
 
Adding webserver user www-data to server's group ..
.. done
 
Setting up log file rotation ..
.. Log file rotation failed! : .. the log file /var/log/virtualmin/example.com_access_log is already being rotated at ../web-lib-funcs.pl line 1427.
 
Creating MySQL login ..
.. done
 
Creating MySQL database wana ..
.. done
 
Creating SSL certificate and private key ..
.. done
 
Adding SSL to Nginx virtual host ..
.. done
 
Creating Webmin user ..
.. done
 
Re-starting DNS server ..
.. done
 
Applying Nginx configuration ..
.. done
 
Re-loading Webmin ..
.. done
 
Saving server details ..
.. done
 
Re-starting DNS server ..
.. done
 
Restoring backup for virtual server example.com ..
Restoring virtual server password, quota and other details ..
.. done
Updating administration password and quotas ..
.. done
 
Restoring Cron jobs ..
.. done
 
Extracting TAR file of home directory ..
.. done
 
Setting ownership of home directory ..
.. done
 
Re-creating records in DNS domain ..
.. done
 
Restoring allowed MySQL hosts ..
.. done
 
Re-loading MySQL database wana ..
.. done
Restoring Webmin ACL files ..
.. done
 
Restoring Nginx webserver configuration ..
.. Nginx virtualhost was not found after restore!?
 
Re-starting DNS server ..
.. done
.. failed! See the progress output above for the reason why.
<?code>

Can you check if a server entry for the domain was created anywhere under the /etc/nginx directory on the destination system?

Can you check if a server entry for the domain was created anywhere under the /etc/nginx directory on the destination system?

yes, an empty file example.com is created in /etc/nginx/sites-available, although example.com_virtualmin-nginx in a backup file is not empty.

Can you post the example.com_virtualmin-nginx file from your backup?

It's strange that it isn't stored inside server { } block, here are the contents of the file

server_name example.com www.example.com;
listen 111.251.131.50;
root /home/example/public_html;
index index.html index.htm index.php;
access_log /var/log/virtualmin/example.com_access_log;
error_log /var/log/virtualmin/example.com_error_log;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_FILENAME /home/example/public_html$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT /home/example/public_html;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param HTTPS $https;
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/php-nginx/14671509331841.sock/socket;
}
listen 111.251.131.50:443 ssl;
ssl_certificate /home/example/ssl.cert;
ssl_certificate_key /home/example/ssl.key;

Ok, that looks fine.

In your main Nginx config file, is there an include for the /etc/nginx/sites-available directory? If so, what does it look like?

yes it's there! I'm using virtualmin on debian jessie x64, you could see this behavior if you'd install it yourself, or I can give you access to a freshly installed VM.

user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
worker_connections 768;
# multi_accept on;
}

http {

##
# Basic Settings
##

sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;

# server_names_hash_bucket_size 64;
# server_name_in_redirect off;

include /etc/nginx/mime.types;
default_type application/octet-stream;

##
# SSL Settings
##

ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;

##
# Logging Settings
##

access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;

##
# Gzip Settings
##

gzip on;
gzip_disable "msie6";

# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

##
# nginx-naxsi config
##
# Uncomment it if you installed nginx-naxsi
##

#include /etc/nginx/naxsi_core.rules;

##
# Virtual Host Configs
##

include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
server_names_hash_bucket_size 128;
}


#mail {
# # See sample authentication script at:
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
# # auth_http localhost/auth.php;
# # pop3_capabilities "TOP" "USER";
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
# server {
# listen     localhost:110;
# protocol   pop3;
# proxy      on;
# }
#
# server {
# listen     localhost:143;
# protocol   imap;
# proxy      on;
# }
#}

If you could give me remote access to a system that's seeing this problem, that would be great!

Please post your public SSH key( cat ~/.ssh/id_rsa.pub ), so I can add it to the system for authentication

This is Jamie's SSH key:

ssh-dss AAAAB3NzaC1kc3MAAACBALPtrQgus8wMeTrxiQREVKNGK1b8S9MLcsVngXsaNL2IpzHzajjDxEhkxARlpREFdvhPB9XEMa8IYVRmScyYaAMoespibzq1A24kcBQ3iLDrgoTb/UiRxv7c84WhQud1YpbteKpcpfG582wste+3FqkzvQ6pbNcI0Kkuruhb0s+HAAAAFQDDRVRFXdmNFNR+N3D/XwkIAb7hhQAAAIB0GN+AIuA9OonKbJpgoKz3TKhWNf6DAm39y8Zb//zMaK8/Lc1FMpOsNI/R4Y6LPvCJeAyDXuf/5OT3+613xu70bSSUi2g4UXA6RM/PlSUhdEH4XmG8SoB9abaIObU2AkH84Dkf25qVlSRAL/5aU/R7InXk7jJYFD+cz7vau/4jKAAAAIA1keU19UdRAzUKpbHFotBso8UnQzurcoFWNq8YtjkV9x32sjHuatab+mSXvjjSV9VDZ1Ru+6h5q/Vf6tr4yUuAYIo9s9LGA/MQgOVl7k+Dsn6N9UCta8/yoDXPMBbYQoiUJ2sOQ0pCaPeYXH6WTbB9edgxRow8WFQjGW26t6cF5Q== dsa-key-20031024 # Virtualmin: Jamie

Jamie, you should be able to login to the server with freshly installed virtualmin: ssh root@139.59.157.242

you will find user password for logging in to virtualmin web interface in /root/virtualmin-password.txt

Thanks, I'm logged in now. Where can I find the backup file that you were having trouble restoring though?

Actually, I was able to reproduce this by creating a domain on your system, backing it up, and then restoring. Turns out that actually the backup process is incomplete - it doesn't save the Nginx config properly, resulting in a broken domain on restore.

We'll fix this, but for now the only work-around is to disable and then re-enable Nginx on these domains post restore.

We'll fix this, but for now the only work-around is to disable and then re-enable Nginx on these domains post restore.

Yes I know this work around, hope you'll fix it in the next release! Do you still need the test server?

No, you can shut it down now. Thanks for setting it up!

Status: Active » Fixed