Comments (6)
Hey
I think one way to approach it is to change the backup name of the original backup using the formatting you used. Create a logfile and append it with the name of the backup.
You can use the tail
command to build an exclude list and remove all backups not on the exclude list. Another possibility is to use the following snippet find /path/to/files* -mtime +5 -exec rm {} \;
That removes everything older than 5 days. I think the tail option will work better, tail -n 5 backups/backup.log
and somehow pipe that into the rm command
like this https://askubuntu.com/questions/830776/remove-file-but-exclude-all-files-in-a-list
It would be easy enough to delete files from Dropbox because there is a rm command for Dropbox-Uploader. rclone on the other hand would be a little trickier. I'll play around with it and see what i can get working.
from iotstack.
Great idea, I did some searching based on the tail command, what do you think about this:
ls -t1 backup* | head -n -5 | xargs rm
- ls -t1 is printing a list, one file/directory per line, of all files in the folder, ordering by the most recent modification date.
- head -n -5 is printing all files except the last 5.
- xargs rm says to delete any file output from the head command.
I tested it and it works for me, keeps the last 5 files starting with "backup".
From this post here
It works for local files, but for Dropbox your backup.log file might be better, In don't know..
from iotstack.
Great, can you fork the project and push up your changes or submit a pull request?
from iotstack.
I would like to help, but I've never done that before. I will read up on how to do that correctly, I wouldn't want to mess something up! I was only running the command ls -t1 backup* | head -n -5 | xargs rm
in terminal, not using your script.
I have now edited the script to the best of my knowledge and it works uploading the files, I changed it so it only appends the date, this way it does at least upload to Dropbox. Deleting of the old files does not work properly:
- Issue 1: If there are less than 5 files in the folder it errors with
rm: missing operand
- Issue 2: Old files can't be deleted :
Permission denied
Here's what I have so far, please let me know how I can help!
docker_backup.sh new script:
Pastebin
Output of my terminal:
pi@raspberrypi:~/IOTstack/scripts $ ./docker_backup.sh
~/IOTstack ~/IOTstack/scripts
Moving old influxdb backups if they exist
backing up influxdb database
influxdb backup complete
compressing stack folders
backup saved to ./backups/backup-2019-11-09.tar.gz
15M ./backups/backup-2019-11-09.tar.gz
uploading to dropbox
> Uploading "/home/pi/IOTstack/backups/backup-2019-11-09.tar.gz" to "/IOTstackBU/backup-2019-11-09.tar.gz"... DONE
rm: cannot remove './backups/backup-2019-11-09.tar.gz': Permission denied
rm: cannot remove './backups/backup01.gz': Permission denied
rm: cannot remove './backups/backup02.gz': Permission denied
last five backup files are saved in ~/IOTstack/backups
~/IOTstack/scripts
pi@raspberrypi:~/IOTstack/scripts $
from iotstack.
OK I spent an hour learning about github branches, forking and pull requests after I got back from work today. I have forked the project and will have a look at improving things, and submit a pull request.
Please don't get too excited though I am quite new to this ;)
from iotstack.
Excellent work, I saw the pull request, we can continue the conversation there
from iotstack.
Related Issues (20)
- InfluxDb data not in backup HOT 3
- menu.sh error HOT 2
- unable to stop and remove Hassio containers in IOTstack HOT 1
- zigbee2mqtt
- menu.sh just checks for current version HOT 2
- Home Assistant Native keeps coming back after removal HOT 1
- Zigbee2MqttAssistant: Unable to connect to MQTT server mosquitto HOT 2
- chown -R 1883:1883 ./volumes/mosquitto does not accept "Y" HOT 1
- ImportError: No module named 'blessed' HOT 1
- running rtl_433 container problem HOT 7
- influxdb.conf ... changing the retention of data HOT 1
- how to retrive an old image HOT 5
- How Do I get rid of Pihole ? I tried everything. HOT 5
- IOT stack vs raspberry pi OS bullseye HOT 5
- installation script incorrectly prompting version types HOT 2
- Concerned about prerequisites HOT 3
- pi.hole only works intermittently. HOT 3
- Cannot start service nodered /dev/ttyAMA0 HOT 2
- can't install new nodes in Node-Red due to no connection of node-red container with internet HOT 1
- i2c in nodered HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from iotstack.