Published: 14 Jul 2026 › Updated: 14 Jul 2026

Just a script I made to back up IPFS files into my personal Kubo.
As most people who know me are aware, I enjoy making experiments with Hive and IPFS aiming at free data distribution in decentralized ways.
#!/bin/bash
HIVE_RPC="https://api.hive.blog"
IPFS_API="http://127.0.0.1:5001"
MFS_DIR="/hive"
LAST_FILE="/home/fernando/Documentos/last.txt"
MAX_JOBS=100
TTL=10
if [ -f "$LAST_FILE" ]; then
LAST=$(<"$LAST_FILE")
else
LAST=$(curl -s "$HIVE_RPC" \
-H "Content-Type: application/json" \
-d '{
"jsonrpc":"2.0",
"method":"condenser_api.get_dynamic_global_properties",
"params":[],
"id":1
}' \
| jq -r '.result.head_block_number')
echo "$LAST" > "$LAST_FILE"
fi
while true; do
HEAD=$(curl -s "$HIVE_RPC" \
-H "Content-Type: application/json" \
-d '{
"jsonrpc":"2.0",
"method":"condenser_api.get_dynamic_global_properties",
"params":[],
"id":1
}' \
| jq -r '.result.head_block_number')
echo "Head block: $HEAD"
curl -X POST -s "$IPFS_API/api/v0/files/mkdir?arg=$MFS_DIR&parents=true"
if (( LAST < HEAD - 100 )); then
TTL=60
else
TTL=3600
fi
while [ "$LAST" -lt "$HEAD" ]; do
echo "Last block: $LAST | HTTP Jobs: $(pgrep -af "pin/add|files/cp" | wc -l) | $((HEAD - LAST)) behind"
echo "$LAST" > "$LAST_FILE"
LAST=$((LAST+1))
BLOCK=$(curl -s "$HIVE_RPC" \
-H "Content-Type: application/json" \
-d "{
\"jsonrpc\":\"2.0\",
\"method\":\"block_api.get_block\",
\"params\":{\"block_num\":$LAST},
\"id\":2
}")
echo "$BLOCK" |
jq -r '.. | strings' |
grep -Eo '(Qm[1-9A-HJ-NP-Za-km-z]{44}|bafy[a-z0-9]{20,})' |
sort -u |
while read -r CID; do
echo "Found CID: $CID"
while [ "$(pgrep -af "pin/add|files/cp" | wc -l)" -ge "$MAX_JOBS" ]; do
sleep 0.1
echo -e "\e[1A\e[KLast block: $LAST | HTTP Jobs: $(pgrep -af "pin/add|files/cp" | wc -l) | $((HEAD - LAST)) behind"
done
FILE="$(date +%s%N)"
curl --max-time "$TTL" -X POST -s "$IPFS_API/api/v0/pin/add?arg=$CID" &&
curl --max-time "$TTL" -X POST -s "$IPFS_API/api/v0/files/cp?arg=/ipfs/$CID&arg=$MFS_DIR/$FILE" &
done
sleep 0.1
done
sleep 3
done
If you trust my capability to run a stable and updated Hive Witness...
Vote for me as your Hive Witness
If you want to support Brazilian creators...
Vote curator @perfilbrasil for Hive Witness
Delegations to
@perfilbrasil are rewarded here.
Leave Just a script I made to back up IPFS files into my personal Kubo. to:
Read more #ipfs posts
Best Posts From Fernando Soder
We have not curated any of fernandosoder's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.
More Posts From Fernando Soder
- Just a script I made to back up IPFS files into my personal Kubo.
- Nala loafing in her first winter with us.
- Misadventures in Korea making other "aliens" afraid for their safety.
- Walking through the park, saw happy scene that brought sad memory.
- Why is cli_wallet serializing transactions in HIVE as STEEM?
- Never trust AI to with your testing parameters. Make them manually by yourself before concluding your code is bad.
- All tests successfuly completed.
- Just testing this Hive Betting App
- Não sei se é fake ou se é real. Mas em todo caso, aqui vai a avaliação.
- United States needs to overwrite several parts of the 12th amendment.