1
Fork 0
mirror of https://github.com/Steffo99/backup-duplicity.git synced 2024-10-16 06:07:25 +00:00

Split backup and restore

This commit is contained in:
Steffo 2023-05-17 14:36:47 +02:00
parent f3809f4b0f
commit d3c8292184
Signed by: steffo
GPG key ID: 2A24051445686895
4 changed files with 76 additions and 50 deletions

View file

@ -43,30 +43,30 @@
<option name="showLibraryContents" value="true" /> <option name="showLibraryContents" value="true" />
<option name="showVisibilityIcons" value="true" /> <option name="showVisibilityIcons" value="true" />
</component> </component>
<component name="PropertiesComponent"><![CDATA[{ <component name="PropertiesComponent">{
"keyToString": { &quot;keyToString&quot;: {
"RunOnceActivity.ShowReadmeOnStart": "true", &quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
"git-widget-placeholder": "main", &quot;git-widget-placeholder&quot;: &quot;main&quot;,
"last_opened_file_path": "/store/Documents/Workspaces/Steffo99/docker-backup-duplicity", &quot;last_opened_file_path&quot;: &quot;/store/Documents/Workspaces/Steffo99/docker-backup-duplicity&quot;,
"node.js.detected.package.eslint": "true", &quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
"node.js.detected.package.tslint": "true", &quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
"node.js.selected.package.eslint": "(autodetect)", &quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
"node.js.selected.package.tslint": "(autodetect)", &quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
"nodejs_package_manager_path": "npm", &quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
"project.structure.last.edited": "Modules", &quot;project.structure.last.edited&quot;: &quot;Modules&quot;,
"project.structure.proportion": "0.0", &quot;project.structure.proportion&quot;: &quot;0.0&quot;,
"project.structure.side.proportion": "0.2", &quot;project.structure.side.proportion&quot;: &quot;0.2&quot;,
"settings.editor.selected.configurable": "editor.preferences.folding", &quot;settings.editor.selected.configurable&quot;: &quot;editor.preferences.folding&quot;,
"vue.rearranger.settings.migration": "true" &quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
}, },
"keyToStringList": { &quot;keyToStringList&quot;: {
"GitStage.ChangesTree.GroupingKeys": [ &quot;GitStage.ChangesTree.GroupingKeys&quot;: [
"directory", &quot;directory&quot;,
"module", &quot;module&quot;,
"repository" &quot;repository&quot;
] ]
} }
}]]></component> }</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" /> <component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager"> <component name="TaskManager">
<task active="true" id="Default" summary="Default task"> <task active="true" id="Default" summary="Default task">
@ -79,7 +79,7 @@
<workItem from="1684100629419" duration="1075000" /> <workItem from="1684100629419" duration="1075000" />
<workItem from="1684324347198" duration="751000" /> <workItem from="1684324347198" duration="751000" />
<workItem from="1684325989651" duration="719000" /> <workItem from="1684325989651" duration="719000" />
<workItem from="1684326731845" duration="82000" /> <workItem from="1684326731845" duration="241000" />
</task> </task>
<task id="LOCAL-00001" summary="Add proper python cryptography requirements"> <task id="LOCAL-00001" summary="Add proper python cryptography requirements">
<created>1684080793392</created> <created>1684080793392</created>
@ -109,7 +109,21 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1684326475873</updated> <updated>1684326475873</updated>
</task> </task>
<option name="localTasksCounter" value="5" /> <task id="LOCAL-00005" summary="Quote variables">
<created>1684326824058</created>
<option name="number" value="00005" />
<option name="presentableId" value="LOCAL-00005" />
<option name="project" value="LOCAL" />
<updated>1684326824058</updated>
</task>
<task id="LOCAL-00006" summary="Fix idea modules">
<created>1684326830505</created>
<option name="number" value="00006" />
<option name="presentableId" value="LOCAL-00006" />
<option name="project" value="LOCAL" />
<updated>1684326830505</updated>
</task>
<option name="localTasksCounter" value="7" />
<servers /> <servers />
</component> </component>
<component name="TypeScriptGeneratedFilesManager"> <component name="TypeScriptGeneratedFilesManager">
@ -131,6 +145,8 @@
<MESSAGE value="Rename stage to &quot;final&quot;" /> <MESSAGE value="Rename stage to &quot;final&quot;" />
<MESSAGE value="Set a+x on backup.sh" /> <MESSAGE value="Set a+x on backup.sh" />
<MESSAGE value="Backup at startup" /> <MESSAGE value="Backup at startup" />
<option name="LAST_COMMIT_MESSAGE" value="Backup at startup" /> <MESSAGE value="Quote variables" />
<MESSAGE value="Fix idea modules" />
<option name="LAST_COMMIT_MESSAGE" value="Fix idea modules" />
</component> </component>
</project> </project>

View file

@ -7,24 +7,9 @@ set -e
# It's duplicity's fault! # It's duplicity's fault!
export PASSPHRASE=$(cat "${DUPLICITY_PASSPHRASE_FILE}") export PASSPHRASE=$(cat "${DUPLICITY_PASSPHRASE_FILE}")
case "$MODE" in echo "Launched in backup mode, performing backup..." >> /dev/stderr
backup) duplicity \
echo "Launched in backup mode, performing backup..." >> /dev/stderr --allow-source-mismatch \
duplicity \ --full-if-older-than "${DUPLICITY_FULL_IF_OLDER_THAN}" \
--allow-source-mismatch \ /mnt \
--full-if-older-than "${DUPLICITY_FULL_IF_OLDER_THAN}" \ "${DUPLICITY_TARGET_URL}"
/mnt \
"${DUPLICITY_TARGET_URL}"
;;
restore)
echo "Launched in restore mode, restoring backup..." >> /dev/stderr
duplicity \
--force \
--allow-source-mismatch \
"${DUPLICITY_TARGET_URL}" \
/mnt
;;
*)
echo "No such mode." >> /dev/stderr
;;
esac

View file

@ -1,7 +1,17 @@
#!/bin/sh #!/bin/sh
echo "Running first backup..." case "$MODE" in
./backup.sh backup)
echo "Running first backup..."
echo "Running cron for daily backups..." ./backup.sh
crond -f -d 5 -l info echo "Running cron for daily backups..."
crond -f -d 5 -l info
;;
restore)
echo "Restoring from latest backup..."
./restore.sh
;;
*)
echo "No such mode." >> /dev/stderr
;;
esac

15
restore.sh Executable file
View file

@ -0,0 +1,15 @@
#!/bin/sh
set -e
# Get secrets from files
# Insecure, but there's not much I can do about it
# It's duplicity's fault!
export PASSPHRASE=$(cat "${DUPLICITY_PASSPHRASE_FILE}")
echo "Launched in restore mode, restoring backup..." >> /dev/stderr
duplicity \
--force \
--allow-source-mismatch \
"${DUPLICITY_TARGET_URL}" \
/mnt