mirror of
https://gitlab.com/octospacc/Configs.git
synced 2025-06-05 21:59:36 +02:00
Auto-Backup $'Sun Sep 22 2024 14:38:14 GMT+0200 (Central European Summer Time)'
This commit is contained in:
@@ -1,14 +1,13 @@
|
||||
#!/usr/bin/env zx
|
||||
|
||||
let BackupsBase = '/Main/Backup';
|
||||
let Time = new Date();
|
||||
const BackupsBase = '/Main/Backup';
|
||||
const GenericBrowserUserAgent = 'Mozilla/5.0 (X11; Linux x86_64; rv:120.0) Gecko/20100101 Firefox/120.0';
|
||||
const Time = new Date();
|
||||
|
||||
Time.Stamp = `${Time.getFullYear()}-${(Time.getMonth() + 1).toString().padStart(2, '0')}-${Time.getDate().toString().padStart(2, '0')}`;
|
||||
cd(BackupsBase);
|
||||
|
||||
const GenericBrowserUserAgent = 'Mozilla/5.0 (X11; Linux x86_64; rv:120.0) Gecko/20100101 Firefox/120.0';
|
||||
|
||||
let [Jobs, Secrets] = [{}, {}];
|
||||
const [Jobs, Secrets] = [{}, {}];
|
||||
|
||||
// Import secrets from sh-formatted file
|
||||
for (let line of (await fs.readFile('./.BackupSecrects.sec', 'utf8')).split('\n')) {
|
||||
@@ -69,7 +68,7 @@ const AltervistaFullBackup = async (domain) => {
|
||||
const [user, pass, key] = Secrets[`${domain.replaceAll('.', '_')}_Backup_Tokens`].split(':');
|
||||
cd(`./${domain}-Git`);
|
||||
await $`rclone sync ${domain}:/ ./www/wp-content/ --progress || true`;
|
||||
// await $`curl -u ${user}:${pass} https://${domain}/wp-json/octt-export-rest/v1/xrss-export?token=${key} > ./WordPress.xml || true`;
|
||||
await $`curl -u ${user}:${pass} https://${domain}/wp-json/octt-export-rest/v1/xrss-export?token=${key} > ./WordPress.xml || true`;
|
||||
await GitPullPush();
|
||||
};
|
||||
|
||||
@@ -176,7 +175,7 @@ Jobs.Cloud_ArticlesBackupPrivate = async () => {
|
||||
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/old/config.php', 'SpaccBBS/old/arrowchat/includes/config.php']) {
|
||||
for (const File of ['Db.sql.tar.xz', 'SpaccBBS/old/config.php', 'SpaccBBS/old/arrowchat/includes/config.php']) {
|
||||
await ccencryptNow(`./${File}`, Secrets.BackupKey_Git_SpaccBBS);
|
||||
};
|
||||
await GitPullPush();
|
||||
@@ -194,7 +193,7 @@ Jobs.Cloud_liminalgici = async () => {
|
||||
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`;
|
||||
for (let File of ['Db.sql.tar.xz', './pixelfed_liminalgici/.env', './pixelfed_liminalgici/config.tar.xz']) {
|
||||
for (const File of ['Db.sql.tar.xz', './pixelfed_liminalgici/.env', './pixelfed_liminalgici/config.tar.xz']) {
|
||||
await ccencryptNow(`./${File}`, Secrets.BackupKey_Git_liminalgici);
|
||||
};
|
||||
//await $`rm ./pixelfed_liminalgici/storage/app/public/m/.gitignore || true`;
|
||||
|
38
Server/Root/Main/Server/Scripts/CleanBackups.zx.mjs
Normal file → Executable file
38
Server/Root/Main/Server/Scripts/CleanBackups.zx.mjs
Normal file → Executable file
@@ -1 +1,39 @@
|
||||
#!/usr/bin/env zx
|
||||
|
||||
const BackupsBase = '/Main/Backup';
|
||||
const TimeLimit = [0, 1, 0];
|
||||
|
||||
let [year, month, day] = TimeLimit;
|
||||
const maxDate = { year, month, day };
|
||||
|
||||
const nowDate = (new Date());
|
||||
//const nowDate = {
|
||||
// year: Number(Time.getFullYear()),
|
||||
// month: Number((Time.getMonth() + 1).toString().padStart(2, '0')),
|
||||
// day: Number(Time.getDate().toString().padStart(2, '0')),
|
||||
//};
|
||||
|
||||
cd(BackupsBase);
|
||||
const allDirsList = String(await $`ls -d */`).trim().split('\n');
|
||||
const gitDirsList = String(await $`ls -d */.git`).trim().split('\n');
|
||||
for (const folder of allDirsList) {
|
||||
if (gitDirsList.includes(`${folder}.git`)) {
|
||||
continue;
|
||||
}
|
||||
const filesList = [
|
||||
...String(await $`ls ${folder}????-??-??.* || true`).trim().split('\n'),
|
||||
...String(await $`ls ${folder}*.????-??-??.* || true`).trim().split('\n'),
|
||||
];
|
||||
for (const file of filesList) {
|
||||
if (file.includes('?')) {
|
||||
continue;
|
||||
}
|
||||
let [year, month, day] = file.split('/')[1].split('-');
|
||||
year = year.split('.').slice(-1)[0];
|
||||
month = month;
|
||||
day = day.split('.')[0];
|
||||
const fileDate = (new Date(`${year}-${month}-${day}`));
|
||||
|
||||
//$`rm`
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user