This commit is contained in:
octospacc 2024-08-02 02:44:45 +02:00
parent 72b99a6cbd
commit 6c288f07f5
5 changed files with 82 additions and 42 deletions

View File

@ -56,6 +56,15 @@ const SimpleBackup = async (Folder, Prefix) => {
await $`ln -s ./${Time.Stamp}.tar.xz ./${Folder}/Latest.tar.xz`;
};
const CompressAndUpdate = async (folder, name, extension) => {
await SimpleCompress(
`./${folder}/${name}.${Time.Stamp}.${extension}`,
`./${folder}/${name}.Latest.${extension}`,
);
await $`rm ./${folder}/${name}.Latest.${extension}.tar.xz || true`;
await $`ln -s ./${name}.${Time.Stamp}.${extension}.tar.xz ./${folder}/${name}.Latest.${extension}.tar.xz`;
};
const AltervistaFullBackup = async (domain) => {
const [user, pass, key] = Secrets[`${domain.replaceAll('.', '_')}_Backup_Tokens`].split(':');
cd(`./${domain}-Git`);
@ -67,22 +76,23 @@ const AltervistaFullBackup = async (domain) => {
const LampBackup = async (folder, table) => {
await SimpleBackup(folder, 'www');
await $`lxc-attach Debian2023 -- mariadb-dump ${table || folder} > ./${folder}/Db.Latest.sql`;
await SimpleCompress(`./${folder}/Db.${Time.Stamp}.sql`, `./${folder}/Db.Latest.sql`);
await $`rm ./${folder}/Db.Latest.sql.tar.xz || true`;
await $`ln -s "./Db.${Time.Stamp}.sql.tar.xz" ./${folder}/Db.Latest.sql.tar.xz`;
await CompressAndUpdate(folder, 'Db', 'sql');
};
const FolderGoCopyForCloud = async (src, dst) => {
cd(`./${dst}`);
await $`rm -rf ./${src} || true`;
await $`cp -rp ../${src}/Latest.d ./${src}`;
if (dst) {
cd(`./${dst}`);
}
await $`rm -rf ./${src} || true`;
await $`cp -rp ../${src}/Latest.d ./${src}`;
await $`rm -rf ./${src}/.git || true`;
};
const Work = async (job) => await within(Jobs[job]);
////////////////////////////////////////////////////////////////////////////////
Jobs.Local_MiscSimpleBackups = async()=>{
Jobs.Local_MiscSimpleBackups = async () => {
await SimpleBackup('FreshRSS', 'www');
await SimpleBackup('n8n-data');
await SimpleBackup('script-server');
@ -92,35 +102,30 @@ Jobs.Local_MiscSimpleBackups = async()=>{
await $`sudo docker start memos`;
};
Jobs.Local_Shiori = async()=>{
Jobs.Local_Shiori = async () => {
await SimpleBackup('shiori-data', 'Shiori');
await $`rm -v ./shiori-data/Latest.d/archive/* || true`;
};
Jobs.Local_SpaccBBS = async()=>{
// ... await LampBackup('SpaccBBS', 'phpBB');
await SimpleBackup('SpaccBBS', 'www');
await $`lxc-attach Debian2023 -- mariadb-dump phpBB > ./SpaccBBS/Db.Latest.sql`;
await SimpleCompress(`./SpaccBBS/Db.${Time.Stamp}.sql`, './SpaccBBS/Db.Latest.sql');
await $`rm ./SpaccBBS/Db.Latest.sql.tar.xz || true`;
await $`ln -s "./Db.${Time.Stamp}.sql.tar.xz" ./SpaccBBS/Db.Latest.sql.tar.xz`;
Jobs.Local_SpaccBBS = () => LampBackup('SpaccBBS', 'phpBB');
Jobs.Local_SpaccBBSNodeBB = async () => {
await SimpleBackup('SpaccBBS-NodeBB');
await $`lxc-attach Debian2023 -- redis-cli -n 2 --rdb - > ./SpaccBBS-NodeBB/Db.Latest.rdb`;
await CompressAndUpdate('SpaccBBS-NodeBB', 'Db', 'rdb');
};
Jobs.Local_liminalgici = async()=>{
await LampBackup('pixelfed_liminalgici');
};
Jobs.Local_liminalgici = () => LampBackup('pixelfed_liminalgici');
Jobs.Local_Doku = async()=>{
await SimpleBackup('dokuwiki', 'www');
};
Jobs.Local_Doku = () => SimpleBackup('dokuwiki', 'www');
Jobs.Cloud_Doku = async()=>{
Jobs.Cloud_Doku = async () => {
await FolderGoCopyForCloud('dokuwiki', 'doku.spacc.eu.org-Git');
await $`rm -rf ./dokuwiki/data/.git ./dokuwiki/data/cache || true`;
await $`rm -rf ./dokuwiki/data/cache || true`;
await GitPullPush();
};
Jobs.Mixed_OctospaccAltervista = async()=>{
Jobs.Mixed_OctospaccAltervista = async () => {
await AltervistaFullBackup('octospacc.altervista.org');
cd('../microblog-mirror');
await $`rm -rf ./_posts ./assets/uploads/* || true`;
@ -140,16 +145,16 @@ Jobs.Mixed_Snippets = async () => {
};
// TODO: setup FTP access and Cookie
Jobs.Mixed_SpacccraftAltervista = async()=>{
Jobs.Mixed_SpacccraftAltervista = async () => {
await AltervistaFullBackup('spacccraft.altervista.org', Secrets.SpacccraftAltervista_Backup_Cookie);
};
// TODO: everything
Jobs.Exter_WikiSpacc = async()=>{
Jobs.Exter_WikiSpacc = async () => {
// ...
};
Jobs.Cloud_ServerBackupLimited = async()=>{
Jobs.Cloud_ServerBackupLimited = async () => {
await GitReclone('Server-Backup-Limited', 'https://gitlab.com/octospacc/Server-Backup-Limited/');
cd('./Server-Backup-Limited');
await BackPathCrypt('FreshRSS', Secrets.BackupKey_Git_FreshRSS);
@ -160,17 +165,13 @@ Jobs.Cloud_ServerBackupLimited = async()=>{
await GitPullPush();
};
Jobs.Cloud_ArticlesBackupPrivate = async()=>{
cd('./Articles-Backup-Private');
await $`rm -rf ./shiori-data || true`;
await $`cp -rp ../shiori-data/Latest.d ./shiori-data`;
Jobs.Cloud_ArticlesBackupPrivate = async () => {
await FolderGoCopyForCloud('shiori-data', 'Articles-Backup-Private');
await GitPullPush();
};
Jobs.Cloud_SpaccBBS = async()=>{
cd('./SpaccBBS-Backup-phpBB-2023');
await $`rm -rf ./SpaccBBS || true`;
await $`cp -rp ../SpaccBBS/Latest.d ./SpaccBBS`;
Jobs.Cloud_SpaccBBS = async () => {
await FolderGoCopyForCloud('SpaccBBS', 'SpaccBBS-Backup-phpBB-2023');
await $`cp ../SpaccBBS/Db.Latest.sql.tar.xz ./Db.sql.tar.xz`;
for (let File of ['Db.sql.tar.xz', 'SpaccBBS/config.php', 'SpaccBBS/arrowchat/includes/config.php']) {
await ccencryptNow(`./${File}`, Secrets.BackupKey_Git_SpaccBBS);
@ -178,10 +179,15 @@ Jobs.Cloud_SpaccBBS = async()=>{
await GitPullPush();
};
Jobs.Cloud_liminalgici = async()=>{
cd('./liminalgici.spacc.eu.org-Git');
await $`rm -rf ./pixelfed_liminalgici || true`;
await $`cp -rp ../pixelfed_liminalgici/Latest.d ./pixelfed_liminalgici`;
Jobs.Cloud_SpaccBBSNodeBB = async () => {
await FolderGoCopyForCloud('SpaccBBS-NodeBB', 'SpaccBBS-NodeBB-2024-Git');
await $`cp ../SpaccBBS-NodeBB/Db.Latest.rdb.tar.xz ./Db.rdb.tar.xz`;
await ccencryptNow('./Db.rdb.tar.xz', Secrets.BackupKey_Git_SpaccBBSNodeBB);
await GitPullPush();
};
Jobs.Cloud_liminalgici = async () => {
await FolderGoCopyForCloud('pixelfed_liminalgici', 'liminalgici.spacc.eu.org-Git');
await $`cp ../pixelfed_liminalgici/Db.Latest.sql.tar.xz ./Db.sql.tar.xz`;
await SimpleCompress('./pixelfed_liminalgici/config');
await $`rm -rf ./pixelfed_liminalgici/config || true`;
@ -191,7 +197,7 @@ Jobs.Cloud_liminalgici = async()=>{
await GitPullPush();
};
Jobs.Cloud_SpaccCraft = async()=>{
Jobs.Cloud_SpaccCraft = async () => {
const McServer="SpaccCraft";
const McEdition="Beta-1.7.3";
const McGit="spacccraft-b1.7.3-backup4";
@ -206,7 +212,7 @@ Jobs.Cloud_SpaccCraft = async()=>{
await GitPullPush();
};
Jobs.Cloud_Private = async()=> await $`sudo -u tux rclone sync /Main/Clouds/octt GDrive-Uni-Crypt:/Clouds.octt --progress`;
Jobs.Cloud_Private = () => $`sudo -u tux rclone sync /Main/Clouds/octt GDrive-Uni-Crypt:/Clouds.octt --progress`;
////////////////////////////////////////////////////////////////////////////////
@ -215,7 +221,7 @@ $`echo Begin ${Time.Stamp} > ${BackupsBase}/Last.log`;
await Work('Local_MiscSimpleBackups');
await Work('Local_Shiori');
await Work('Local_SpaccBBS');
//await Work('Local_SpaccBBS_NodeBB');
await Work('Local_SpaccBBSNodeBB');
await Work('Local_liminalgici');
await Work('Local_Doku');
@ -227,6 +233,7 @@ await Work('Mixed_OctospaccAltervista');
await Work('Cloud_ServerBackupLimited');
await Work('Cloud_ArticlesBackupPrivate');
await Work('Cloud_SpaccBBS');
await Work('Cloud_SpaccBBSNodeBB');
await Work('Cloud_liminalgici');
await Work('Cloud_Doku');
await Work('Cloud_SpaccCraft');

View File

@ -0,0 +1 @@
#!/usr/bin/env zx

View File

@ -71,6 +71,7 @@ server {
location /new { #~ ^/(new$|new/) {
proxy_http_version 1.1;
proxy_pass http://localhost:4567;
proxy_set_header Host bbs.spacc.eu.org;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
@ -87,6 +88,7 @@ server {
location /.well-known/webfinger {
proxy_http_version 1.1;
proxy_pass http://localhost:4567/new/.well-known/webfinger;
proxy_set_header Host bbs.spacc.eu.org;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;

View File

@ -0,0 +1,28 @@
server {
listen 80;
listen 443 ssl;
server_name bbs.spacc.eu.org bbs.spaccsoj3trhzowrrblzb5m6hgkwu6syghnmhett7gvxbrz5zhsrs4ad.onion;
ssl_certificate /etc/letsencrypt/live/bbs.spacc.eu.org/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/bbs.spacc.eu.org/privkey.pem;
ssl_prefer_server_ciphers on;
error_log /var/log/nginx/SpaccBBS.error.log;
access_log /var/log/nginx/SpaccBBS.access.log;
location / {
proxy_http_version 1.1;
proxy_pass http://localhost:4567;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
location /.well-known/webfinger {
proxy_http_version 1.1;
proxy_pass http://localhost:4567/new/.well-known/webfinger;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}

View File

@ -20,6 +20,8 @@ server {
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
sub_filter '</head>' '<link rel="alternate" type="application/rss+xml" href="/nojs?rss=1"/></head>';
sub_filter_once on;
}
location /nojs {
proxy_pass http://127.0.0.1/MemosViewer.php;