konditerov.ru

Позднее Ctrl + ↑

Бекап VestaCP в облако на примере Google Drive (Ubuntu 16.04)

Эта инструкция написана для меня, но воспользоваться ей может любой, нужны базовые знания консоли linux, минут 30 на настройку.

Для начала нам необходимо установить Rclone:
Заходим под рутом

sudo su

Скачиваем и устанавливаем Rclone

curl https://rclone.org/install.sh | sudo bash

Запускаем настройку Rclone

rclone config

Создаем новый профиль Rclone

No remotes found — make a new one
n) New remote
s) Set configuration password
q) Quit config

n/s/q> n

Задаем имя (тут вы можете назвать как угодно)

name> gdrive

Выбираем сервис.
У меня гуглдиск оказался под номером 13, возможно в дальнейшем номер изменится.

13 / Google Drive
\ «drive»

Storage> 13

Тут нам необходимо получить авторизацию у google.
Переходим по ссылке и авторизуемся под своим аккаунтом: https://code.google.com/apis/console/

Создаем проект и даем ему имя → Заходим в проект → Заходим в библиотеки → Ищем Google Drive API → Включаем → Переходим в Учетные данные → Настроить окно запроса доступа → Заходим в Учетные данные → Создаем Идентификатор клиента OAuthДругие типы → Получаем ключи:
Идентификатор клиента и Секретный код клиента, они нам и нужны.

Скринкаст:

Продолжаем настройку Rclone
Вводим Идентификатор клиента

client_id> Ваш идентификатор клиента (Client ID)

Вводим Секретный код клиента

client_secret> Ваш код клиента (Secret code)

далее выбираем

Scope that rclone should use when requesting access from drive.
Enter a string value. Press Enter for the default («„).
Choose a number from below, or type in your own value
1 / Full access all files, excluding Application Data Folder.
\ „drive“
2 / Read-only access to file metadata and file contents.
\ „drive.readonly“
/ Access to files created by rclone only.
3 | These are visible in the drive website.
| File authorization is revoked when the user deauthorizes the app.
\ „drive.file“
/ Allows read and write access to the Application Data folder.
4 | This is not visible in the drive website.
\ „drive.appfolder“
/ Allows read-only access to file metadata but
5 | does not allow any access to read or download file content.
\ „drive.metadata.readonly“

scope> 1

Далее настройка упрощается, нажимаем Enter

ID of the root folder
Leave blank normally.

Fill in to access «Computers» folders (see docs), or for rclone to use
a non root folder as its starting point.

Note that if this is blank, the first time rclone runs it will fill it
in with the ID of the root folder.

Enter a string value. Press Enter for the default («„).

root_folder_id>

Еще раз нажимаем Enter

Service Account Credentials JSON file path
Leave blank normally.
Needed only if you want use SA instead of interactive login.
Enter a string value. Press Enter for the default («„).

service_account_file>

Далее

Edit advanced config? (y/n)
y) Yes
n) No (default)

y/n> n

Далее

Remote config
Use auto config?
* Say Y if not sure
* Say N if you are working on a remote or headless machine
y) Yes (default)
n) No

y/n> n

Переходим по этой ссылке в браузере и копируем ваш верификационный код

Please go to the following link: https://accounts.google.com/o/oauth2/auth?.....
Log in and authorize rclone for access

Enter verification code> Ваш код

Далее
Configure this as a team drive?
y) Yes
n) No (default)

y/n> n

И в завершении настройки получаете такое сообщение:

——————————
[gdrive]
type = drive
client_id = Ваш идентификатор клиента (Client ID)
client_secret = Ваш код клиента (Secret code)
scope = drive
token = {«access_token»:» ¯\_(ツ)_/¯ «,«expiry»:«2020-05-07T20:49:03.221799741+03:00»}
——————————
y) Yes this is OK (default)
e) Edit this remote
d) Delete this remote

Проверяем настройки и вводим y

y/e/d> y

Дальше программа показывает нам созданный профиль и спрашивает что делать дальше

Current remotes:

Name Type
==== ====
gdrive drive

e) Edit existing remote
n) New remote
d) Delete remote
r) Rename remote
c) Copy remote
s) Set configuration password
q) Quit config

Выходим

e/n/d/r/c/s/q> q

Rclone установлен и настроен

Пробуем скопировать содержимое папки на свой сервер (критично к регистру)

rclone copy /backup/ gdrive:Backup/Myserver/ -P

Если всё копируется, то будем настраивать синхронизацию по времени.
Т. к. веста не умеет от рута запускать скрипты, настроим крон сами:

sudo nano /etc/crontab

И в конце файла добавляем следующий код (выполняется каждый день в 4 часа):

0 4 * * * root rclone sync /backup/ gdrive:Backup/Myserver/

P.s. Настройка Cron.

Миграция VestaCP

Всё под рутом:

Чтобы не было ошибки:

command not found

Нужно обновить пусть, он сбрасывается при каждом logout:

export PATH=$PATH:/usr/local/vesta/bin

Далее:

v-backup-users
ls /backup
admin.2018-04-11_13-07-02.tar  exampleuser.2018-04-11_13-07-02.tar

Копируем на новый сервер:

scp /backup/* root@panel.example.com:/backup/

На новом сервере:

v-restore-user admin admin.2018-04-11_13-07-02.tar

Ubuntu при закрытой крышке ноутбука

У меня домашний сервер VestaPC на базе ноутбука samsung n150 plus хрен знает какого года, стоит на столе, ну и крышка закрыта. Для работы с закрытой крышкой нашел такое решение:

sudo nano /etc/systemd/logind.conf

Найти:

#HandleLidSwitch=suspend

Заменить:

HandleLidSwitch=ignore
sudo service systemd-logind stop
sudo service systemd-logind start
sudo reboot

VestaCP install php-zip

Для полноценной работы MODX нужен zip, другими движками не пользуюсь

Для Ubuntu 16.04 i386

Остановить php-fpm в настройках панели

sudo apt-get install php7.0-zip

После этого, можно пользоваться https://github.com/ilyautkin/simpleUpdater

AjaxForm FormIt Цели

yandex

[[!AjaxForm?
     &snippet=`FormIt`
     &successMessage=`Сообщение успешно отправлено
     <script>yaCounterXXXXXXXX.reachGoal('target');</script>`
]]

Google Analytics

[[!AjaxForm?
     &snippet=`FormIt`
     &successMessage=`Сообщение успешно отправлено
     <script>ga('send', 'event', 'form' 'submit'); yaCounterXXXXXXXX.reachGoal('target');</script>`
]]
 95   2019   modx

Конфиг nginx Эгея for vestacp

Настройка Эгеи под VestaCP (nginx)

В папку с правами 644 пользователь root:
nginx + php-fpm
/usr/local/vesta/data/templates/web/nginx/php-fpm5

egea.tpl

server {
    http2      on;
    listen      %ip%:%web_port%;
    server_name %domain_idn% %alias_idn%;
    root        %docroot%;
    index       index.php index.html index.htm;
    access_log  /var/log/nginx/domains/%domain%.log combined;
    access_log  /var/log/nginx/domains/%domain%.bytes bytes;
    error_log   /var/log/nginx/domains/%domain%.error.log error;
#   if you need to rewrite www to non-www uncomment bellow
#   if ($host != '%domain%' ) {
#       rewrite      ^/(.*)$  http://%domain%/$1  permanent;
#    }
    location = /favicon.ico {
        log_not_found off;
        access_log off;
    }

    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }

    location / {
        try_files $uri $uri/ @rewrite;
        location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|css|js)$ {
            expires     max;
        }
    }
    location @rewrite {
        rewrite ^/(.*)$ /index.php?go=$uri;
    }

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_pass %backend_lsnr%;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $request_filename;
        include /etc/nginx/fastcgi_params;
    }

    error_page  403 /error/404.html;
    error_page  404 /error/404.html;
    error_page  500 502 503 504 /error/50x.html;

    location /error/ {
        alias   %home%/%user%/web/%domain%/document_errors/;
    }

    location ~* "/\.(htaccess|htpasswd)$" {
        deny    all;
        return  404;
    }

    location /vstats/ {
        alias   %home%/%user%/web/%domain%/stats/;
        include %home%/%user%/conf/web/%domain%.auth*;
    }

    include     /etc/nginx/conf.d/phpmyadmin.inc*;
    include     /etc/nginx/conf.d/phppgadmin.inc*;
    include     /etc/nginx/conf.d/webmail.inc*;

    include     %home%/%user%/conf/web/nginx.%domain%.conf*;
}

и файл
egea.stpl

server {
    http2      on;
    listen      %ip%:%web_ssl_port% ssl
    server_name %domain_idn% %alias_idn%;
    root        %sdocroot%;
    index       index.php index.html index.htm;
    access_log  /var/log/nginx/domains/%domain%.log combined;
    access_log  /var/log/nginx/domains/%domain%.bytes bytes;
    error_log   /var/log/nginx/domains/%domain%.error.log error;

    ssl_certificate      %ssl_pem%;
    ssl_certificate_key  %ssl_key%;
#   if you need to rewrite www to non-www uncomment bellow
#   if ($host != '%domain%' ) {
#       rewrite      ^/(.*)$  https://%domain%/$1  permanent;
#    }
    location = /favicon.ico {
        log_not_found off;
        access_log off;
    }

    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }

    location / {
        try_files $uri $uri/ @rewrite;
        location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|css|js)$ {
            expires     max;
        }
    }
    location @rewrite {
        rewrite ^/(.*)$ /index.php?go=$uri;
    }

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_pass %backend_lsnr%;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $request_filename;
        include /etc/nginx/fastcgi_params;
    }

    error_page  403 /error/404.html;
    error_page  404 /error/404.html;
    error_page  500 502 503 504 /error/50x.html;

    location /error/ {
        alias   %home%/%user%/web/%domain%/document_errors/;
    }

    location ~* "/\.(htaccess|htpasswd)$" {
        deny    all;
        return  404;
    }

    location /vstats/ {
        alias   %home%/%user%/web/%domain%/stats/;
        include %home%/%user%/conf/web/%domain%.auth*;
    }

    include     /etc/nginx/conf.d/phpmyadmin.inc*;
    include     /etc/nginx/conf.d/phppgadmin.inc*;
    include     /etc/nginx/conf.d/webmail.inc*;

    include     %home%/%user%/conf/web/snginx.%domain%.conf*;
}

потом выбираем Web Template NGINX — egea и пользуемся

 163   2018   nginx   vesta   vestacp   web
 40   2018   macos   web
Ранее Ctrl + ↓