Compare commits
5 Commits
v1.1.2
..
1ae54a46e7
| Author | SHA1 | Date | |
|---|---|---|---|
| 1ae54a46e7 | |||
| 918fe80566 | |||
| 073a392f19 | |||
| 703ab3b07d | |||
| b2cc478c85 |
@@ -62,7 +62,7 @@ jobs:
|
|||||||
name: Deploy to Kubernetes
|
name: Deploy to Kubernetes
|
||||||
needs: release-please
|
needs: release-please
|
||||||
if: ${{ needs.release-please.outputs.release_created }}
|
if: ${{ needs.release-please.outputs.release_created }}
|
||||||
runs-on: [ k3s-lan-01 ]
|
runs-on: [ k3s-internal-htz-01 ]
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
".": "1.1.2"
|
".": "1.2.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,12 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## [1.2.0](https://github.com/JDB-NET/opnsense-sftp/compare/v1.1.2...v1.2.0) (2025-11-01)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* :sparkles: latest backup api endpoint - /api/backups/latest ([703ab3b](https://github.com/JDB-NET/opnsense-sftp/commit/703ab3b07da0b60f91d674fd6f4a39d3c45ae1e6))
|
||||||
|
|
||||||
## [1.1.2](https://github.com/JDB-NET/opnsense-sftp/compare/v1.1.1...v1.1.2) (2025-11-01)
|
## [1.1.2](https://github.com/JDB-NET/opnsense-sftp/compare/v1.1.1...v1.1.2) (2025-11-01)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -342,6 +342,23 @@ def delete_backup(backup_id):
|
|||||||
return redirect(url_for('backups'))
|
return redirect(url_for('backups'))
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/api/backups/latest')
|
||||||
|
def api_latest_backups():
|
||||||
|
"""API endpoint to get the latest backup date and time for each instance."""
|
||||||
|
latest_backups = db.get_latest_backup_per_instance()
|
||||||
|
|
||||||
|
# Format the response
|
||||||
|
result = []
|
||||||
|
for item in latest_backups:
|
||||||
|
result.append({
|
||||||
|
'instance_id': item['instance_id'],
|
||||||
|
'instance_name': item['instance_name'],
|
||||||
|
'latest_backup': item['latest_backup'].isoformat() if item['latest_backup'] else None
|
||||||
|
})
|
||||||
|
|
||||||
|
return jsonify(result)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
app.run(host='0.0.0.0', port=5000, debug=True)
|
app.run(host='0.0.0.0', port=5000, debug=True)
|
||||||
|
|
||||||
|
|||||||
+23
@@ -279,4 +279,27 @@ class Database:
|
|||||||
except Error as e:
|
except Error as e:
|
||||||
logger.error(f"Error getting instance by ID: {e}")
|
logger.error(f"Error getting instance by ID: {e}")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def get_latest_backup_per_instance(self) -> List[Dict[str, Any]]:
|
||||||
|
"""Get the latest backup date and time for each instance."""
|
||||||
|
try:
|
||||||
|
with self.get_connection() as conn:
|
||||||
|
cursor = conn.cursor(dictionary=True)
|
||||||
|
cursor.execute("""
|
||||||
|
SELECT
|
||||||
|
o.id as instance_id,
|
||||||
|
o.name as instance_name,
|
||||||
|
o.identifier as instance_identifier,
|
||||||
|
MAX(b.uploaded_at) as latest_backup
|
||||||
|
FROM opnsense_instances o
|
||||||
|
LEFT JOIN backups b ON o.id = b.instance_id
|
||||||
|
GROUP BY o.id, o.name, o.identifier
|
||||||
|
ORDER BY o.name
|
||||||
|
""")
|
||||||
|
results = cursor.fetchall()
|
||||||
|
cursor.close()
|
||||||
|
return results
|
||||||
|
except Error as e:
|
||||||
|
logger.error(f"Error getting latest backup per instance: {e}")
|
||||||
|
return []
|
||||||
|
|
||||||
|
|||||||
+6
-6
@@ -24,7 +24,7 @@ spec:
|
|||||||
name: "opnsense-sftp"
|
name: "opnsense-sftp"
|
||||||
env:
|
env:
|
||||||
- name: DB_HOST
|
- name: DB_HOST
|
||||||
value: "10.10.2.27"
|
value: "10.10.25.4"
|
||||||
- name: DB_PORT
|
- name: DB_PORT
|
||||||
value: "3306"
|
value: "3306"
|
||||||
- name: DB_NAME
|
- name: DB_NAME
|
||||||
@@ -38,7 +38,7 @@ spec:
|
|||||||
- name: ADMIN_PASSWORD
|
- name: ADMIN_PASSWORD
|
||||||
value: "CVk7QKIB3MjZ8mt6MxES"
|
value: "CVk7QKIB3MjZ8mt6MxES"
|
||||||
- name: SFTP_PUBLIC_HOST
|
- name: SFTP_PUBLIC_HOST
|
||||||
value: "10.10.2.29"
|
value: "10.10.25.8"
|
||||||
- name: SFTP_PUBLIC_PORT
|
- name: SFTP_PUBLIC_PORT
|
||||||
value: "30222"
|
value: "30222"
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
@@ -49,12 +49,12 @@ spec:
|
|||||||
volumes:
|
volumes:
|
||||||
- name: keys-volume
|
- name: keys-volume
|
||||||
nfs:
|
nfs:
|
||||||
server: 10.10.2.5
|
server: 10.10.25.2
|
||||||
path: /srv/Backups/OPNsense/keys
|
path: /srv/k3s/opnsense/keys
|
||||||
- name: backups-volume
|
- name: backups-volume
|
||||||
nfs:
|
nfs:
|
||||||
server: 10.10.2.5
|
server: 10.10.25.2
|
||||||
path: /srv/Backups/OPNsense/backups
|
path: /srv/k3s/opnsense/backups
|
||||||
---
|
---
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Service
|
kind: Service
|
||||||
|
|||||||
@@ -42,18 +42,11 @@
|
|||||||
|
|
||||||
<button
|
<button
|
||||||
type="submit"
|
type="submit"
|
||||||
class="w-full bg-orange-500 hover:bg-orange-600 text-white font-medium py-2 px-4 rounded-md transition-colors duration-200"
|
class="w-full bg-orange-500 hover:bg-orange-600 text-white font-medium py-2 px-4 rounded-md transition-colors duration-200 hover:cursor-pointer">
|
||||||
>
|
|
||||||
Sign In
|
Sign In
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<div class="mt-6 p-4 bg-neutral-700 rounded-md">
|
|
||||||
<p class="text-xs text-neutral-400">
|
|
||||||
Default credentials: <code class="text-orange-400">admin / admin</code>
|
|
||||||
<br>Please change these after first login!
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user