История изменений
Исправление LINUX-ORG-RU, (текущая версия) :
#!/usr/bin/env lua
local sites =
{
tmp = "/tmp/"..os.time().."/";
--------------------------------
ssh = "USER@HOST:/home/USER/backup"; --каталог backup обязан быть создан заранее, на хосте приёмнике
--------------------------------
root = "/home/hosting/project/";
--------------------------------
postfix = "/htdocs/data/";
--------------------------------
list =
{
'bilge-ru';
'dragonserw-ru';
'gibibyte-ru';
'honeybeegood-ru';
'sokhumi-ru';
'yeya-ru';
'yeysk-su';
};
--------------------------------
content = "media pages";
--------------------------------
}
function sites:backup()
os.execute("mkdir "..self.tmp);
for _,site in pairs(self.list) do
print("[zip] pack -> "..site.." to "..self.tmp..site..".zip");
os.execute("cd "..self.root..site..self.postfix.."&& zip -9 -r "..self.tmp.."/"..site..".zip "..self.content);
end
print("[scp] send -> "..self.ssh);
os.execute("scp -r "..self.tmp.." "..self.ssh..'/'..os.time());
os.execute("rm -rd "..self.tmp);
end
sites:backup();
dron@gnu:~/back$ chmod +x backup.lua
dron@gnu:~/back$
dron@gnu:~/back$ ./backup.lua
[zip] pack -> bilge-ru to /tmp/1682437761/bilge-ru.zip
adding: media/ (stored 0%)
adding: pages/ (stored 0%)
[zip] pack -> dragonserw-ru to /tmp/1682437761/dragonserw-ru.zip
adding: media/ (stored 0%)
adding: pages/ (stored 0%)
[zip] pack -> gibibyte-ru to /tmp/1682437761/gibibyte-ru.zip
adding: media/ (stored 0%)
adding: pages/ (stored 0%)
[zip] pack -> honeybeegood-ru to /tmp/1682437761/honeybeegood-ru.zip
adding: media/ (stored 0%)
adding: pages/ (stored 0%)
[zip] pack -> sokhumi-ru to /tmp/1682437761/sokhumi-ru.zip
adding: media/ (stored 0%)
adding: pages/ (stored 0%)
[zip] pack -> yeya-ru to /tmp/1682437761/yeya-ru.zip
adding: media/ (stored 0%)
adding: pages/ (stored 0%)
[zip] pack -> yeysk-su to /tmp/1682437761/yeysk-su.zip
adding: media/ (stored 0%)
adding: pages/ (stored 0%)
[scp] send -> dron@localhost:/home/dron/
yeysk-su.zip 100% 302 517.4KB/s 00:00
yeya-ru.zip 100% 302 542.8KB/s 00:00
bilge-ru.zip 100% 302 630.5KB/s 00:00
gibibyte-ru.zip 100% 302 353.4KB/s 00:00
sokhumi-ru.zip 100% 302 432.8KB/s 00:00
honeybeegood-ru.zip 100% 302 505.6KB/s 00:00
dragonserw-ru.zip 100% 302 432.7KB/s 00:00
Исходная версия LINUX-ORG-RU, :
#!/usr/bin/env lua
local sites =
{
tmp = "/tmp/"..os.time().."/";
--------------------------------
ssh = "USER@HOST:/home/USER/backup";
--------------------------------
root = "/home/hosting/project/";
--------------------------------
postfix = "/htdocs/data/";
--------------------------------
list =
{
'bilge-ru';
'dragonserw-ru';
'gibibyte-ru';
'honeybeegood-ru';
'sokhumi-ru';
'yeya-ru';
'yeysk-su';
};
--------------------------------
content = "media pages";
--------------------------------
}
function sites:backup()
os.execute("mkdir "..self.tmp);
for _,site in pairs(self.list) do
print("[zip] pack -> "..site.." to "..self.tmp..site..".zip");
os.execute("cd "..self.root..site..self.postfix.."&& zip -9 -r "..self.tmp.."/"..site..".zip "..self.content);
end
print("[scp] send -> "..self.ssh);
os.execute("scp -r "..self.tmp.." "..self.ssh..'/'..os.time());
os.execute("rm -rd "..self.tmp);
end
sites:backup();
dron@gnu:~/back$ chmod +x backup.lua
dron@gnu:~/back$
dron@gnu:~/back$ ./backup.lua
[zip] pack -> bilge-ru to /tmp/1682437761/bilge-ru.zip
adding: media/ (stored 0%)
adding: pages/ (stored 0%)
[zip] pack -> dragonserw-ru to /tmp/1682437761/dragonserw-ru.zip
adding: media/ (stored 0%)
adding: pages/ (stored 0%)
[zip] pack -> gibibyte-ru to /tmp/1682437761/gibibyte-ru.zip
adding: media/ (stored 0%)
adding: pages/ (stored 0%)
[zip] pack -> honeybeegood-ru to /tmp/1682437761/honeybeegood-ru.zip
adding: media/ (stored 0%)
adding: pages/ (stored 0%)
[zip] pack -> sokhumi-ru to /tmp/1682437761/sokhumi-ru.zip
adding: media/ (stored 0%)
adding: pages/ (stored 0%)
[zip] pack -> yeya-ru to /tmp/1682437761/yeya-ru.zip
adding: media/ (stored 0%)
adding: pages/ (stored 0%)
[zip] pack -> yeysk-su to /tmp/1682437761/yeysk-su.zip
adding: media/ (stored 0%)
adding: pages/ (stored 0%)
[scp] send -> dron@localhost:/home/dron/
yeysk-su.zip 100% 302 517.4KB/s 00:00
yeya-ru.zip 100% 302 542.8KB/s 00:00
bilge-ru.zip 100% 302 630.5KB/s 00:00
gibibyte-ru.zip 100% 302 353.4KB/s 00:00
sokhumi-ru.zip 100% 302 432.8KB/s 00:00
honeybeegood-ru.zip 100% 302 505.6KB/s 00:00
dragonserw-ru.zip 100% 302 432.7KB/s 00:00