mirror of https://gitlab.com/octospacc/Configs.git
This commit is contained in:
parent
9c2cee4061
commit
8773ae26e2
|
@ -3,7 +3,6 @@
|
|||
let BackupsBase = '/Main/Backup';
|
||||
let Time = new Date();
|
||||
|
||||
// Note: not padding the year to 5 digits will break the scripts in ~8 millenia. The line should be fixed.
|
||||
Time.Stamp = `${Time.getFullYear()}-${(Time.getMonth() + 1).toString().padStart(2, '0')}-${Time.getDate().toString().padStart(2, '0')}`;
|
||||
cd(BackupsBase);
|
||||
|
||||
|
@ -20,81 +19,124 @@ for (let line of (await fs.readFile('./.BackupSecrects.sec', 'utf8')).split('\n'
|
|||
Secrets[key] = val;
|
||||
};
|
||||
|
||||
const Hash2 = async (BaseKey, Salt) => await $`echo "$(echo "${BaseKey}$(echo ${Salt} | sha512sum | base64 -w0)" | sha512sum | base64 -w0)"`.toString();
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
const Hash2 = async (BaseKey, Salt) => (await $`echo "${BaseKey}$(echo ${Salt} | sha512sum | base64 -w0)" | sha512sum | base64 -w0`).toString().trim();
|
||||
|
||||
const ccencryptNow = async (File, BaseKey) => {
|
||||
await $`ccrypt -e -f -K"${Hash2(BaseKey, Time.Stamp)}" ${File}`;
|
||||
await $`ccrypt -e -f -K"${await Hash2(BaseKey, Time.Stamp)}" ${File}`;
|
||||
$`echo ${Time.Stamp} > ${File}.info`;
|
||||
};
|
||||
|
||||
const GitPush = async () => $`git add . && git commit -m "Auto-Backup ${Time}" && git push`;
|
||||
const GitPullPush = async () => await $`git pull; git add . && git commit -m "Auto-Backup ${Time}" && git push || true`;
|
||||
|
||||
const BackPathCrypt = async (Folder, Key, Ext) => {
|
||||
Ext ||= '.tar.xz';
|
||||
const File = `${Folder}${Ext}`;
|
||||
await $`cp "../${Folder}/Latest${Ext}" "./${File}" && ccencryptNow "./${File}" "${Key}"`;
|
||||
await $`cp "../${Folder}/Latest${Ext}" "./${File}"`;
|
||||
await ccencryptNow(`./${File}`, Key);
|
||||
};
|
||||
|
||||
const SimpleCompress = async (Src, Dst) => await $`tar cJSf "${Dst}.tar.xz" ${Src}`;
|
||||
const SimpleCompress = async (Dst, Src) => await $`rm ${Dst}.tar.xz || true; tar cJSf "${Dst}.tar.xz" ${Src}`;
|
||||
|
||||
const SimpleBackup = async (Folder, Prefix) => {
|
||||
await $`mkdir -vp "./${Folder}"`;
|
||||
// ...
|
||||
//await $`mkdir -vp "./${Folder}"`;
|
||||
//await $`rm "./${Folder}/Latest.tar.xz" || true`;
|
||||
//await $`rm -rf "./${Folder}/Latest.d" || true`;
|
||||
//await $`cp -rp "/Main/Server/${Prefix}/${Folder}" "./${Folder}/Latest.d"`;
|
||||
//await SimpleCompress(`./${Folder}/${Time.Stamp}`, `./${Folder}/Latest.d`);
|
||||
//await $`ln -s "./${Time.Stamp}.tar.xz" "./${Folder}/Latest.tar.xz"`;
|
||||
await $`mkdir -vp ./${Folder}`;
|
||||
await $`rm ./${Folder}/Latest.tar.xz || true`;
|
||||
await $`rm -rf ./${Folder}/Latest.d || true`;
|
||||
await $`cp -rp /Main/Server/${Prefix || ''}/${Folder} ./${Folder}/Latest.d`;
|
||||
await SimpleCompress(`./${Folder}/${Time.Stamp}`, `./${Folder}/Latest.d`);
|
||||
await $`ln -s ./${Time.Stamp}.tar.xz ./${Folder}/Latest.tar.xz`;
|
||||
};
|
||||
|
||||
const Work = async (Job) => await within(Jobs[Job]);
|
||||
|
||||
///////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Jobs.Local_Simple_Backup = async()=>{
|
||||
SimpleBackup('FreshRSS', 'www');
|
||||
SimpleBackup('n8n-data');
|
||||
SimpleBackup('script-server');
|
||||
SimpleBackup('docker-mailserver');
|
||||
Jobs.Local_MiscSimpleBackups = async()=>{
|
||||
await SimpleBackup('FreshRSS', 'www');
|
||||
await SimpleBackup('n8n-data');
|
||||
await SimpleBackup('script-server');
|
||||
await SimpleBackup('docker-mailserver');
|
||||
};
|
||||
|
||||
Jobs.Local_Shiori = async()=>{
|
||||
SimpleBackup('shiori-data', 'Shiori');
|
||||
$`rm -v ./shiori-data/Latest.d/archive/*`;
|
||||
await SimpleBackup('shiori-data', 'Shiori');
|
||||
await $`rm -v ./shiori-data/Latest.d/archive/* || true`;
|
||||
};
|
||||
|
||||
Jobs.Local_SpaccBBS = async()=>{
|
||||
|
||||
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.Exter = async()=>{
|
||||
// ...
|
||||
};
|
||||
|
||||
Jobs.Cloud_ServerBackupLimited = async()=>{
|
||||
cd('./Server-Backup-Limited');
|
||||
BackPathCrypt('FreshRSS', Secrets.BackupKey_Git_FreshRSS);
|
||||
BackPathCrypt('n8n-data', Secrets.BackupKey_Git_n8n);
|
||||
BackPathCrypt('script-server', Secrets.BackupKey_Git_scriptserver);
|
||||
BackPathCrypt('docker-mailserver', Secrets.BackupKey_Git_dockermailserver);
|
||||
GitPush();
|
||||
await BackPathCrypt('FreshRSS', Secrets.BackupKey_Git_FreshRSS);
|
||||
await BackPathCrypt('n8n-data', Secrets.BackupKey_Git_n8n);
|
||||
await BackPathCrypt('script-server', Secrets.BackupKey_Git_scriptserver);
|
||||
await BackPathCrypt('docker-mailserver', Secrets.BackupKey_Git_dockermailserver);
|
||||
await GitPullPush();
|
||||
};
|
||||
|
||||
Jobs.Cloud_ArticlesBackupPrivate = async()=>{
|
||||
cd('./Articles-Backup-Private');
|
||||
await $`rm -rf ./shiori-data`;
|
||||
await $`rm -rf ./shiori-data || true`;
|
||||
await $`cp -rp ../shiori-data/Latest.d ./shiori-data`;
|
||||
GitPush();
|
||||
await GitPullPush();
|
||||
};
|
||||
|
||||
Jobs.Cloud_SpaccBBS = async()=>{
|
||||
cd('./SpaccBBS-Backup-phpBB-2023');
|
||||
await $`rm -rf ./SpaccBBS || true`;
|
||||
await $`cp -rp ../SpaccBBS/Latest.d ./SpaccBBS`;
|
||||
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);
|
||||
};
|
||||
await GitPullPush();
|
||||
};
|
||||
|
||||
Jobs.Cloud_SpaccCraft = async()=>{
|
||||
|
||||
const McServer="SpaccCraft";
|
||||
const McEdition="Beta-1.7.3";
|
||||
const McGit="spacccraft-b1.7.3-backup4";
|
||||
const DestPath=`${BackupsBase}/${McGit}`;
|
||||
if (fs.existsSync(DestPath)) {
|
||||
cd(`${BackupsBase}/${McServer}`);
|
||||
await $`rm -rf "${DestPath}/${McEdition}" || true`;
|
||||
await $`cp ./*.sh "${DestPath}/" || true`;
|
||||
await $`cp -r "./${McEdition}/Latest.d" "${DestPath}/${McEdition}"`;
|
||||
};
|
||||
cd(DestPath);
|
||||
await GitPullPush();
|
||||
};
|
||||
|
||||
///////////////////////////////////////
|
||||
Jobs.Cloud_Private = async()=> await $`sudo -u tux rclone sync -v /Main/Clouds/octt GDrive-Uni-Crypt:/`;
|
||||
|
||||
Work('Local_Simple_Backup');
|
||||
Work('Local_Shiori');
|
||||
Work('Local_SpaccBBS');
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Work('Cloud_ServerBackupLimited');
|
||||
Work('Cloud_ArticlesBackupPrivate');
|
||||
Work('Cloud_SpaccBBS');
|
||||
Work('Cloud_SpaccCraft');
|
||||
await Work('Local_MiscSimpleBackups');
|
||||
await Work('Local_Shiori');
|
||||
await Work('Local_SpaccBBS');
|
||||
await Work('Exter');
|
||||
|
||||
await Work('Cloud_ServerBackupLimited');
|
||||
await Work('Cloud_ArticlesBackupPrivate');
|
||||
await Work('Cloud_SpaccBBS');
|
||||
await Work('Cloud_SpaccCraft');
|
||||
//await Work('Cloud_Private');
|
||||
|
||||
$`echo ${Time.Stamp} > ${BackupsBase}/Last.log`;
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
#!/bin/sh
|
||||
cd "$( dirname "$( realpath "$0" )" )"
|
||||
while true; do
|
||||
|
||||
qemu-system-x86_64 \
|
||||
-accel kvm \
|
||||
-cpu host \
|
||||
-smp 3 \
|
||||
-m 1400M \
|
||||
-hda ./FedoraWorkstation38.qcow2 \
|
||||
-device e1000,netdev=net0 \
|
||||
-netdev user,id=net0,hostfwd=tcp::33893-:3389,hostfwd=udp::33893-:3389 \
|
||||
-spice port=5953,password=tux.FedoraWorkstation38 \
|
||||
;
|
||||
# -cdrom /Main/Transfers/Storage/Fedora-Workstation-Live-x86_64-38-1.6.iso \
|
||||
# -vnc :10 \
|
||||
# -display none \
|
||||
|
||||
sleep 500
|
||||
done
|
|
@ -10,10 +10,9 @@ qemu-system-x86_64 \
|
|||
-hda ./Lubuntu2022NonProxied.qcow2 \
|
||||
-device e1000,netdev=net0 \
|
||||
-netdev user,id=net0,hostfwd=tcp::33891-:3389,hostfwd=udp::33891-:3389,hostfwd=tcp::50991-:5900,hostfwd=udp::50991-:5900 \
|
||||
-vnc :10 \
|
||||
-display none \
|
||||
;
|
||||
# -cdrom ./lubuntu-22.04.2-desktop-amd64.iso \
|
||||
# -netdev user,id=net0,hostfwd=tcp::33891-:3389,hostfwd=udp::33891-:3389 \
|
||||
# -vnc :10 \
|
||||
# -display none \
|
||||
|
||||
|
|
|
@ -21,7 +21,9 @@ while true; do
|
|||
-netdev user,id=net0,hostfwd=tcp::3389-:3389,hostfwd=udp::3389-:3389 \
|
||||
-display none \
|
||||
;
|
||||
# -bios /usr/share/qemu/OVMF.fd \
|
||||
# -device intel-hda \
|
||||
# -device hda-duplex \
|
||||
# -audiodev driver=none,id=none \
|
||||
# -cdrom ./SERVER_EVAL_x64FRE_en-us.iso \
|
||||
# -vnc :10 \
|
||||
# -display none \
|
||||
|
|
|
@ -52,8 +52,8 @@ T.is = (question) => {
|
|||
|
||||
///////////////////////////////////////
|
||||
|
||||
//T.is({ h:'03', m_:'05' })
|
||||
// && Work('Backup', ()=>{ $`zx /Main/Server/Scripts/BackupAll.zx.mjs` });
|
||||
T.is({ h:'03', m_:'05' })
|
||||
&& Work('Backup', ()=>{ $`zx /Main/Server/Scripts/BackupAll.zx.mjs` });
|
||||
|
||||
T.is({ _D_:'9', h:'04', m_:'05' })
|
||||
&& Work('Certs', ()=>{ $`sh /Main/Server/Scripts/RenewCerts.sh` });
|
||||
|
|
Loading…
Reference in New Issue